Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.9] - 2025-10-09

### Added
- **Two New Usage Segments**: Enhanced API usage monitoring with dedicated segments
- **Usage5Hour Segment**: Displays 5-hour usage percentage with reset time (e.g., `24% -> 11am`)
- **Usage7Day Segment**: Displays 7-day usage percentage with full reset datetime (e.g., `12% -> Oct 9, 5am`)
- Both segments share efficient API cache to minimize redundant calls
- Dynamic circle icons that change based on utilization level
- Automatic UTC to local timezone conversion for reset times
- Disabled by default (opt-in via config or TUI)

### Changed
- **API Cache Structure**: Updated to store both 5-hour and 7-day reset times separately
- Cache now includes `five_hour_resets_at` and `seven_day_resets_at` fields
- Backward compatible with graceful handling of old cache files
- **Segment ID Enum**: Added `Usage5Hour` and `Usage7Day` variants
- **All Theme Files**: Updated all 9 built-in themes to include new usage segments
- **TUI Components**: Enhanced UI components with new segment name mappings

### Technical Details
- New time formatting functions: `format_5hour_reset_time()` and `format_7day_reset_time()`
- Public API for `UsageSegment::load_usage_cache()` to enable cache sharing
- Added mock preview data for new segments in TUI configurator
- All UI match statements updated to handle new segment IDs

## [1.0.4] - 2025-08-28

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ccometixline"
version = "1.0.8"
version = "1.0.9"
edition = "2021"
description = "CCometixLine (ccline) - High-performance Claude Code StatusLine tool written in Rust"
authors = ["Haleclipse"]
Expand Down
103 changes: 102 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,43 @@ New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.claude\ccline"
copy target\release\ccometixline.exe "$env:USERPROFILE\.claude\ccline\ccline.exe"
```

### Running a Forked Version

If you're running a forked version with the latest changes, you'll need to rebuild and reinstall after pulling updates:

```bash
# Navigate to your forked repository
cd /path/to/your/CCometixLine

# Pull latest changes
git pull

# Rebuild the binary
cargo build --release

# Install to local directory (recommended for testing)
# Linux/macOS
cp target/release/ccometixline ~/.claude/ccline/ccline

# Or install to system location (if using Homebrew path)
# macOS
cp target/release/ccometixline /opt/homebrew/bin/ccline

# Or install to system location
# Linux
sudo cp target/release/ccometixline /usr/local/bin/ccline

# Verify version
ccline --version
```

**After updating the binary**, if you've added new segments or themes:
1. Remove old theme cache: `rm -rf ~/.claude/ccline/themes`
2. Reinitialize if needed: `ccline --init`
3. Use TUI configurator to enable new segments: `ccline -c`

**Note**: The binary name in the repository is `ccometixline`, but it's renamed to `ccline` for convenience.

## Usage

### Configuration Management
Expand Down Expand Up @@ -244,6 +281,32 @@ Shows simplified Claude model names:

Token usage percentage based on transcript analysis with context limit tracking.

### Usage Segments

Three usage tracking segments are available for monitoring Claude API usage:

**Usage (Original)** - Shows combined usage info:
- Displays 5-hour usage percentage
- Shows 7-day reset date in compact format
- Format: `24% Β· 10-7-2` (24% used, resets Oct 7 at 2am)

**Usage (5-hour)** - Focused 5-hour window:
- Shows 5-hour usage percentage with reset time
- Format: `24% β†’ 11am`
- Ideal for monitoring short-term API limits

**Usage (7-day)** - Weekly usage tracking:
- Shows 7-day usage percentage with full reset datetime
- Format: `12% β†’ Oct 9:5am`
- Perfect for tracking weekly quota

All usage segments:
- Share the same API call and cache (efficient)
- Use dynamic circle icons that change with utilization level
- Are disabled by default (enable via config or TUI)
- Auto-convert reset times from UTC to local timezone
- **Support threshold-based warning colors** (see below)

## Configuration

CCometixLine supports full configuration via TOML files and interactive TUI:
Expand All @@ -261,7 +324,45 @@ All segments are configurable with:
- Color customization
- Format options

Supported segments: Directory, Git, Model, Usage, Time, Cost, OutputStyle
Supported segments: Directory, Git, Model, ContextWindow, Usage, Usage5Hour, Usage7Day, Cost, Session, OutputStyle, Update

### Threshold-Based Warning Colors

Usage segments (Usage5Hour and Usage7Day) support dynamic color changes based on utilization thresholds. This allows you to get visual warnings when your API usage approaches limits.

**Configuration example:**

```toml
[[segments]]
id = "usage_5hour"
enabled = true

[segments.colors]
# Default colors (used when under warning threshold)
icon.c16 = 14 # Cyan
text.c16 = 14

[segments.options]
warning_threshold = 60 # Turn yellow at 60% usage
critical_threshold = 80 # Turn red at 80% usage
warning_color.c16 = 11 # Yellow (16-color palette)
critical_color.c16 = 9 # Red (16-color palette)
```

**How it works:**
- **< 60%**: Uses default segment colors (cyan)
- **β‰₯ 60%**: Text changes to warning color (yellow)
- **β‰₯ 80%**: Text changes to critical color (red)

You can customize thresholds and colors for each usage segment independently. The colors can be specified using:
- `c16`: 16-color ANSI palette (0-15)
- `c256`: 256-color palette (0-255)
- RGB values (e.g., `{r = 255, g = 165, b = 0}`)

**Common color codes:**
- Yellow: `c256 = 226` or `c16 = 11`
- Red: `c256 = 196` or `c16 = 9`
- Orange: `c256 = 208` or `c256 = 214`


## Requirements
Expand Down
2 changes: 2 additions & 0 deletions src/config/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ pub enum SegmentId {
Git,
ContextWindow,
Usage,
Usage5Hour,
Usage7Day,
Cost,
Session,
OutputStyle,
Expand Down
51 changes: 51 additions & 0 deletions src/core/segments/color_utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use crate::config::AnsiColor;
use ratatui::style::Color;

/// Serializes an AnsiColor to a JSON string for metadata storage
pub fn serialize_ansi_color_to_json(color: &AnsiColor) -> String {
match color {
AnsiColor::Color256 { c256 } => {
serde_json::json!({"c256": c256}).to_string()
}
AnsiColor::Color16 { c16 } => {
serde_json::json!({"c16": c16}).to_string()
}
AnsiColor::Rgb { r, g, b } => {
serde_json::json!({"r": r, "g": g, "b": b}).to_string()
}
}
}

/// Converts a 16-color ANSI code to a ratatui Color
/// This is used throughout the TUI for consistent color rendering
pub fn c16_to_ratatui_color(c16: u8) -> Color {
match c16 {
0 => Color::Black,
1 => Color::Red,
2 => Color::Green,
3 => Color::Yellow,
4 => Color::Blue,
5 => Color::Magenta,
6 => Color::Cyan,
7 => Color::White,
8 => Color::DarkGray,
9 => Color::LightRed,
10 => Color::LightGreen,
11 => Color::LightYellow,
12 => Color::LightBlue,
13 => Color::LightMagenta,
14 => Color::LightCyan,
15 => Color::Gray,
_ => Color::White, // Default fallback
}
}

/// Converts an AnsiColor to a ratatui Color
/// Handles all three color formats: c16, c256, and RGB
pub fn ansi_color_to_ratatui(color: &AnsiColor) -> Color {
match color {
AnsiColor::Color16 { c16 } => c16_to_ratatui_color(*c16),
AnsiColor::Color256 { c256 } => Color::Indexed(*c256),
AnsiColor::Rgb { r, g, b } => Color::Rgb(*r, *g, *b),
}
}
5 changes: 5 additions & 0 deletions src/core/segments/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod color_utils;
pub mod context_window;
pub mod cost;
pub mod directory;
Expand All @@ -7,6 +8,8 @@ pub mod output_style;
pub mod session;
pub mod update;
pub mod usage;
pub mod usage_5hour;
pub mod usage_7day;

use crate::config::{InputData, SegmentId};
use std::collections::HashMap;
Expand Down Expand Up @@ -34,3 +37,5 @@ pub use output_style::OutputStyleSegment;
pub use session::SessionSegment;
pub use update::UpdateSegment;
pub use usage::UsageSegment;
pub use usage_5hour::Usage5HourSegment;
pub use usage_7day::Usage7DaySegment;
Loading