Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
02cdcb2
feat: add dedicated 5-hour and 7-day usage segments
ekain-fr Oct 9, 2025
fbb7b46
docs: add instructions for running forked version
ekain-fr Oct 9, 2025
c36feb3
refactor: use Unicode arrow (β†’) instead of ASCII arrow (->) in usage …
ekain-fr Oct 9, 2025
278750a
refactor: use colon separator in 7-day usage reset time format
ekain-fr Oct 9, 2025
1714ce2
feat: add threshold-based warning colors for usage segments
ekain-fr Oct 9, 2025
8b7b92a
feat(tui): add interactive threshold editing (Phase 2)
ekain-fr Oct 9, 2025
2777109
fix(tui): update preview with threshold colors and new usage format
ekain-fr Oct 9, 2025
c2801f2
refactor: use 16-color palette for threshold defaults
ekain-fr Oct 9, 2025
85bae80
feat: add threshold-based bold text options for usage segments
ekain-fr Oct 9, 2025
6004642
feat(tui): add warning/critical bold fields to usage segment configur…
ekain-fr Oct 9, 2025
4f0cdfc
refactor: address code review feedback with shared color utilities
ekain-fr Oct 10, 2025
2f169af
Merge pull request #2 from ekain-fr/feat/enhanced-usage-segments
ekain-fr Oct 10, 2025
aafa46d
feat: add warning/critical thresholds to context window segment
ekain-fr Oct 10, 2025
b7407e7
feat: add threshold options to usage segments in remaining themes
ekain-fr Oct 10, 2025
e13f54a
feat: add warning/critical thresholds to context window segment
ekain-fr Oct 10, 2025
3a810c0
refactor: address code review feedback
ekain-fr Oct 10, 2025
1ed1983
Merge feat/context-window-thresholds into master
ekain-fr Oct 10, 2025
30b9778
feat: add dirty file count display to git segment
ekain-fr Oct 11, 2025
3aca994
feat(tui): add Git segment options to TUI configurator
ekain-fr Oct 11, 2025
7e6a419
fix(tui): update Git segment preview to reflect show_sha and show_dir…
ekain-fr Oct 11, 2025
9d3755b
fix: remove space between status indicator and dirty count
ekain-fr Oct 11, 2025
c580e21
fix(tui): remove space in preview dirty count display
ekain-fr Oct 11, 2025
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
3 changes: 2 additions & 1 deletion Cargo.lock

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

3 changes: 2 additions & 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 All @@ -27,6 +27,7 @@ semver = { version = "1.0", optional = true }
chrono = { version = "0.4", features = ["serde"], optional = true }
dirs = { version = "5.0", optional = true }
regex = "1.0"
once_cell = "1.19"



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),
}
}
14 changes: 13 additions & 1 deletion src/core/segments/context_window.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{Segment, SegmentData};
use super::{color_utils, threshold_utils, Segment, SegmentData};
use crate::config::{InputData, ModelConfig, SegmentId, TranscriptEntry};
use std::collections::HashMap;
use std::fs;
Expand Down Expand Up @@ -62,6 +62,18 @@ impl Segment for ContextWindowSegment {
let context_used_rate = (context_used_token as f64 / context_limit as f64) * 100.0;
metadata.insert("tokens".to_string(), context_used_token.to_string());
metadata.insert("percentage".to_string(), context_used_rate.to_string());

// Check if we need to apply threshold-based color override
if let Some(color) = threshold_utils::get_color_for_utilization(SegmentId::ContextWindow, context_used_rate) {
// Serialize the color to JSON for metadata using shared helper
let color_json = color_utils::serialize_ansi_color_to_json(&color);
metadata.insert("text_color_override".to_string(), color_json);
}

// Check if we need to apply threshold-based bold override
if let Some(should_bold) = threshold_utils::should_be_bold(SegmentId::ContextWindow, context_used_rate) {
metadata.insert("text_bold_override".to_string(), should_bold.to_string());
}
}
None => {
metadata.insert("tokens".to_string(), "-".to_string());
Expand Down
Loading