feat: add --no-optional-locks flag to all git commands#47
feat: add --no-optional-locks flag to all git commands#47ekain-fr wants to merge 26 commits intoHaleclipse:masterfrom
Conversation
Add two new usage segments for enhanced API usage monitoring: - Usage5Hour: Displays 5-hour usage with reset time (24% -> 11am) - Usage7Day: Displays 7-day usage with reset datetime (12% -> Oct 9, 5am) Features: - Efficient shared API cache to minimize redundant calls - Dynamic circle icons based on utilization level - Automatic UTC to local timezone conversion - Both segments disabled by default (opt-in) Technical changes: - Updated API cache structure with separate reset time fields - Added time formatting functions for 5-hour and 7-day displays - Updated all 9 built-in themes to include new segments - Enhanced UI components with new segment name mappings - Made ApiUsageCache public for cross-module access 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive documentation for developers running a forked version of CCometixLine, including: - How to rebuild after pulling updates - Installation options (local vs system-wide) - Steps to clear old theme cache when new segments are added - Note about binary naming (ccometixline -> ccline) Also includes version bump to 1.0.9 in Cargo.lock. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…segments Replace ASCII arrow (->) with Unicode rightwards arrow (→) for cleaner display in the 5-hour and 7-day usage segments. Changes: - usage_5hour.rs: Format now shows "24% → 11am" - usage_7day.rs: Format now shows "12% → Oct 9, 5am" - README.md: Updated documentation examples to reflect new format 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Change 7-day usage segment format from "Oct 9, 5am" to "Oct 9:5am" for more compact display by replacing comma-space with colon. Changes: - usage.rs: Updated format_7day_reset_time() to use colon separator - README.md: Updated documentation example to show "Oct 9:5am" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add dynamic color changing for Usage5Hour and Usage7Day segments based on utilization thresholds. This provides visual warnings when API usage approaches limits. Features: - Configurable warning threshold (default: 60%) - Configurable critical threshold (default: 80%) - Custom colors for warning and critical states - Independent configuration per segment - Supports c16, c256, and RGB color formats Changes: - theme_*.rs: Added threshold options to usage segment definitions - warning_threshold: 60 - critical_threshold: 80 - warning_color: c256 226 (yellow) - critical_color: c256 196 (red) - usage_5hour.rs: Implemented get_color_for_utilization() to determine threshold-based colors and add text_color_override to metadata - usage_7day.rs: Same threshold logic as usage_5hour - statusline.rs: Check for text_color_override in metadata and apply instead of default segment colors - README.md: Added comprehensive documentation for threshold configuration Usage example: ```toml [[segments]] id = "usage_5hour" [segments.options] warning_threshold = 60 critical_threshold = 80 warning_color.c256 = 226 # Yellow critical_color.c256 = 196 # Red ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implement full TUI support for threshold-based warning colors. Users can now interactively configure warning/critical thresholds and colors directly in the TUI configurator without editing config files. Features: - New threshold fields shown for Usage5Hour and Usage7Day segments - Interactive threshold editing (cycle through 40/50/60/70/80/90/95%) - Color picker integration for warning/critical colors - Dynamic field navigation based on segment type - Real-time preview updates Changes: - segment_list.rs: Extended FieldSelection enum with: - WarningThreshold - CriticalThreshold - WarningColor - CriticalColor - settings.rs: Conditional display of threshold fields - Show threshold fields only for usage segments - Extract and display current threshold values from options - Display warning/critical colors with proper formatting - app.rs: Full editing support - Dynamic field count (11 for usage segments, 7 for others) - Navigation logic updated for threshold fields - Threshold cycling (Enter to cycle through common values) - Color picker opens for WarningColor/CriticalColor - apply_selected_color stores colors in segment options Usage: 1. Open TUI: ccline -c 2. Navigate to Usage5Hour or Usage7Day segment 3. Use Up/Down to select threshold fields 4. Press Enter to cycle threshold values or open color picker 5. Press [S] to save configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Update TUI preview component to reflect the latest changes to usage segments: Changes: - Use Unicode arrow (→) instead of ASCII (->) - Update 7-day format: "Oct 9:5am" instead of "Oct 9, 5am" - Add get_threshold_color() method to apply threshold-based color overrides - Update mock utilization values to demonstrate threshold states: - Usage5Hour: 65% (triggers warning color - yellow) - Usage7Day: 85% (triggers critical color - red) - Update dynamic icons to match utilization levels The preview now accurately shows threshold-based coloring in real-time, allowing users to see how their threshold settings affect the display before saving the configuration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Update default threshold colors to use 16-color ANSI palette (c16) instead of 256-color palette (c256) for better terminal compatibility and consistency with the TUI display. Changes: - theme_default.rs: Changed warning_color from c256:226 to c16:11, critical_color from c256:196 to c16:9 - theme_gruvbox.rs: Same color updates for both usage segments - theme_cometix.rs: Same color updates for both usage segments - All themes: Updated usage_7day default icon/text color from c16:11 (yellow) to c16:12 (light blue) for visual differentiation - README.md: Updated documentation to show c16 defaults Color mappings: - Warning: c16:11 (Yellow) - equivalent to c256:226 - Critical: c16:9 (Light Red) - equivalent to c256:196 Benefits: - Better compatibility with terminals that don't support 256 colors - Matches TUI configurator display format (16:11, 16:9) - More consistent with other segment color definitions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add warning_bold and critical_bold options to usage segments, allowing text to become bold when usage exceeds warning or critical thresholds. This provides additional visual prominence for high usage states. Features: - New options: warning_bold (default: false), critical_bold (default: true) - Automatic bold text when thresholds are exceeded - Independent control for warning and critical states - Works alongside threshold color changes Default behavior: - Default/Gruvbox themes: warning=normal, critical=bold - Cometix theme: warning=bold, critical=bold (matches theme style) Changes: - usage_5hour.rs: Added should_be_bold() method to check bold options and apply text_bold_override to metadata - usage_7day.rs: Same should_be_bold() logic for 7-day segment - statusline.rs: Check for text_bold_override in metadata and apply instead of default text_bold style - theme_*.rs: Added warning_bold and critical_bold options to all themes Usage example: ```toml [[segments]] id = "usage_5hour" [segments.options] warning_bold = true # Make text bold at 60% usage critical_bold = true # Make text bold at 80% usage ``` Result: Critical usage now displays in bold red text for maximum visibility! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…ator Add full TUI support for configuring warning_bold and critical_bold options in Usage (5-hour) and Usage (7-day) segments. Changes: - Add WarningBold and CriticalBold to FieldSelection enum - Display bold toggle fields in settings panel with [✓]/[ ] indicators - Add color swatches (██) for warning/critical color fields - Update navigation to handle 13 fields for usage segments (was 11) - Add Enter key handlers to toggle bold options - Show status messages when bold settings are changed - Update preview in real-time when bold options are toggled Users can now press Enter on "Warning Bold" or "Critical Bold" fields to toggle them on/off, making it easy to configure threshold-based bold text styling without manual TOML editing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Address code review comments by introducing shared helper functions and clarifying utilization value format: **New shared utilities (color_utils.rs):** - serialize_ansi_color_to_json(): Eliminates duplicated color serialization - c16_to_ratatui_color(): Centralizes 16-color ANSI to ratatui::Color mapping - ansi_color_to_ratatui(): Handles all color formats (c16, c256, RGB) **Refactored files:** - usage_5hour.rs: Use serialize_ansi_color_to_json(), clarify utilization format - usage_7day.rs: Use serialize_ansi_color_to_json(), clarify utilization format - settings.rs: Replace 6 duplicated color mappings with color_utils helpers - app.rs: Use serialize_ansi_color_to_json() for warning/critical colors - mod.rs: Export new color_utils module **Documentation improvements:** - Added comments clarifying utilization values are percentages (0-100) - Added comments explaining division by 100 converts to normalized values (0-1) - This addresses reviewer questions about get_circle_icon expectations **Code quality improvements:** - Reduced duplication: ~100 lines of repeated color mapping code eliminated - Single source of truth: Color conversion logic now centralized - Maintainability: Future color format changes only require updating one place - Consistency: All color conversions now use the same helper functions Addresses review comments from PR code review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Fork enhancements: Usage segments with threshold styling and comprehensive improvements
Extend threshold-based color and bold text support to the context window segment, matching the implementation from usage segments (5-hour/7-day). This provides visual feedback when context usage exceeds configurable warning (60%) and critical (80%) thresholds. Additionally, fix missing threshold options in usage segments for minimal, nord, and all powerline themes. These themes were missing the threshold configurations that were already present in default, gruvbox, and cometix themes. Changes: - context_window.rs: Add get_color_for_utilization() and should_be_bold() methods - app.rs, settings.rs: Include ContextWindow in threshold segment checks for TUI - All 9 themes: Add threshold options to context_window_segment() functions - minimal, nord, powerline themes: Add missing threshold options to usage segments Default thresholds: - Warning: 60% (yellow, normal weight) - Critical: 80% (red, bold) - Cometix theme: Both warning and critical use bold text 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add missing warning/critical threshold configurations to usage 5-hour and 7-day segments in minimal, nord, and all powerline themes. These themes were missing the threshold options that were already present in default, gruvbox, and cometix themes. Adds the following threshold options to usage segments: - warning_threshold: 60% (triggers yellow color) - critical_threshold: 80% (triggers red color with bold text) - warning_color: yellow (ANSI c16: 11) - critical_color: red (ANSI c16: 9) - warning_bold: false - critical_bold: true This ensures all themes have consistent threshold-based visual feedback for usage tracking segments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Extend threshold-based color and bold text support to the context window segment, matching the implementation from usage segments (5-hour/7-day). This provides visual feedback when context usage exceeds configurable warning (60%) and critical (80%) thresholds. **Implementation:** - context_window.rs: Add get_color_for_utilization() and should_be_bold() methods - Uses color_utils::serialize_ansi_color_to_json() from PR Haleclipse#41 - Checks utilization against warning_threshold (default 60%) and critical_threshold (default 80%) - Returns appropriate color/bold overrides based on threshold levels - app.rs, settings.rs: Include ContextWindow in threshold segment checks for TUI - Enables threshold configuration UI for context window segment - Adds 6 threshold fields (thresholds, colors, bold flags) to segment settings - All 9 themes: Add threshold options to context_window_segment() functions - warning_threshold: 60%, critical_threshold: 80% - warning_color: c16=11 (yellow), critical_color: c16=9 (red) - Cometix/Gruvbox: Both thresholds use bold (warning_bold/critical_bold: true) - Default/Minimal/Nord/Powerline themes: Only critical uses bold **Dependencies:** - Requires color_utils module from PR Haleclipse#41 (enhanced-usage-segments) - This PR should not be merged until PR Haleclipse#41 is merged **Default behavior:** - Warning: 60% utilization → yellow text, normal weight (bold in Cometix/Gruvbox) - Critical: 80% utilization → red text, bold weight - Below warning: Uses default segment colors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit addresses all feedback from the PR code review by introducing
shared utilities, config caching, and improving code maintainability.
**Changes:**
1. **New threshold_utils module (addresses duplication concerns)**
- Created src/core/segments/threshold_utils.rs
- Extracts shared threshold logic from context_window, usage_5hour, usage_7day
- Implements config caching using once_cell to avoid repeated disk I/O
- Provides centralized functions:
* get_thresholds_for_segment(): Extract warning/critical thresholds
* get_color_for_utilization(): Determine color based on utilization
* should_be_bold(): Determine bold text based on utilization
2. **Refactored segments to use shared utilities**
- context_window.rs: Removed duplicated get_color_for_utilization/should_be_bold
- usage_5hour.rs: Removed duplicated threshold methods
- usage_7day.rs: Removed duplicated threshold methods
- All segments now call threshold_utils functions with SegmentId parameter
- Reduced ~200 lines of duplicated code
3. **Fixed date formatting (Comment 1)**
- usage.rs: Changed format_7day_reset_time output from "Oct 9:5am" to "Oct 9, 5am"
- Added comma for better readability and consistency with comment suggestion
4. **Added field count constants (Comment 3)**
- app.rs: Defined DEFAULT_SEGMENT_FIELD_COUNT (7) and THRESHOLD_SEGMENT_FIELD_COUNT (13)
- Replaced inline hardcoded values with named constants
- Improved maintainability and reduced error risk
5. **Fixed potential panic in color picker (Comment 4)**
- app.rs: Replaced unwrap() with proper error handling using if-let Ok()
- Prevents panic if serialize_ansi_color_to_json returns unexpected format
- Safely handles JSON parsing failures for WarningColor and CriticalColor
**Dependencies:**
- Added once_cell = "1.19" to Cargo.toml for config caching
**Testing:**
- ✅ Compiles successfully with cargo build --release
- ✅ All threshold functionality preserved with shared utilities
- ✅ Config caching reduces disk I/O for threshold checks
**Impact:**
- Eliminated ~200 lines of duplicated code
- Improved performance with config caching
- Better maintainability with centralized threshold logic
- Reduced risk of inconsistencies across segments
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This brings the context window threshold feature and code review improvements into master, including: - Context window threshold support (warning/critical color/bold) - Shared threshold utilities with config caching - Refactored usage segments to use shared utilities - Improved date formatting for 7-day reset time - Field count constants instead of hardcoded values - Safe error handling in color picker All code review feedback has been addressed. Conflict resolution: Accepted refactored version from feature branch which uses shared threshold_utils instead of duplicated methods.
Enhances the Git segment to display the number of dirty (modified, staged, untracked) files next to the status indicator. This provides immediate visibility into repository state. - Add dirty_count field to GitInfo struct - Modify get_status() to count files from git status --porcelain output - Display format: "● 5" (dirty), "⚠ 3" (conflicts), "✓" (clean) - Add show_dirty_count configuration option (default: true in all themes) - Add with_dirty_count() builder method for segment configuration - Maintain backward compatibility when option is disabled 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Adds show_sha and show_dirty_count configuration options to the TUI configurator for the Git segment. Users can now toggle these options interactively using the TUI. Changes: - Add ShowSha and ShowDirtyCount to FieldSelection enum - Display Git options in Settings panel (show_sha, show_dirty_count) - Add GIT_SEGMENT_FIELD_COUNT constant (9 fields) - Implement field navigation for Git segment options - Add toggle handlers for show_sha and show_dirty_count - Update field index mapping for Git segment TUI Navigation: - Navigate to Git segment in Segments panel - Switch to Settings panel (Tab) - Use ↑/↓ to select "Show SHA" or "Show Dirty Count" - Press Enter to toggle the option - Preview updates in real-time 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…ty_count options The TUI preview was using hardcoded mock data for the Git segment that didn't respect the show_sha and show_dirty_count configuration options. This made it appear that toggling these options in the TUI had no effect on the preview. Changes: - Read show_sha and show_dirty_count from segment config in preview - Dynamically build Git segment secondary status based on options - Mock data now shows: - "● 5" when show_dirty_count is enabled (5 dirty files) - "●" when show_dirty_count is disabled - "a1b2c3d" SHA appended when show_sha is enabled - Proper status parts joining like real Git segment Preview now displays: - show_dirty_count OFF, show_sha OFF: "feat/demo ● ↑2" - show_dirty_count ON, show_sha OFF: "feat/demo ● 5 ↑2" - show_dirty_count OFF, show_sha ON: "feat/demo ● ↑2 a1b2c3d" - show_dirty_count ON, show_sha ON: "feat/demo ● 5 ↑2 a1b2c3d" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…ment Display dirty count directly adjacent to status indicator (●5 instead of ● 5) for better visual compactness. Updated both the Git segment implementation and TUI configurator preview to maintain consistency. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add install.sh script that automates the process of: - Building release binary with cargo - Creating installation directory in Claude config path - Copying and renaming binary to 'ccline' - Auto-detecting shell (bash/zsh) and updating appropriate rc file - Adding to PATH (safe to run multiple times) Useful for installing from source on new servers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add support for reading OAuth credentials from $CLAUDE_CONFIG_DIR/.credentials.json as a fallback when the default ~/.claude/.credentials.json is not available. This provides flexibility for users who need to store credentials in custom locations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add support for reading OAuth credentials from $CLAUDE_CONFIG_DIR/.credentials.json with proper priority ordering. When CLAUDE_CONFIG_DIR is set, it takes precedence over the default ~/.claude/.credentials.json location. Priority order: 1. Try $CLAUDE_CONFIG_DIR/.credentials.json (if env var is set) 2. Fall back to ~/.claude/.credentials.json (default) 3. Return None if both fail This respects explicit user configuration via environment variable while maintaining backward compatibility with existing installations that use the default path. Use cases: - Custom Claude Code installations in non-standard locations - Containerized environments with custom config directories - Multi-user setups with isolated config paths - CI/CD pipelines with temporary config locations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Prevents creation of .git/index.lock files during statusline operations by adding the --no-optional-locks flag to all git command invocations. This eliminates potential conflicts with concurrent user git operations. Changes: - Added flag to is_git_repository() git rev-parse command - Added flag to get_branch() git branch and git symbolic-ref commands - Added flag to get_status() git status command (most critical) - Added flag to get_commit_count() git rev-list command - Added flag to get_sha() git rev-parse command Compatible with Git 2.15+ (released 2017). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Reviewer's GuideThis pull request enhances Git segment stability by adding ER diagram for updated ApiUsageCache structureerDiagram
API_USAGE_CACHE {
five_hour_utilization float
seven_day_utilization float
five_hour_resets_at varchar
seven_day_resets_at varchar
cached_at varchar
}
Class diagram for new and updated Usage segmentsclassDiagram
class UsageSegment {
+load_usage_cache() Option<ApiUsageCache>
+get_circle_icon(utilization: f64) String
+format_5hour_reset_time(reset_time_str: Option<&str>) String
+format_7day_reset_time(reset_time_str: Option<&str>) String
}
class Usage5HourSegment {
+collect(input: &InputData) Option<SegmentData>
+new() Usage5HourSegment
}
class Usage7DaySegment {
+collect(input: &InputData) Option<SegmentData>
+new() Usage7DaySegment
}
class ApiUsageCache {
+five_hour_utilization: f64
+seven_day_utilization: f64
+five_hour_resets_at: Option<String>
+seven_day_resets_at: Option<String>
+cached_at: String
}
Usage5HourSegment ..> UsageSegment : uses
Usage7DaySegment ..> UsageSegment : uses
UsageSegment --> ApiUsageCache : cache
Usage5HourSegment --> ApiUsageCache : reads
Usage7DaySegment --> ApiUsageCache : reads
Class diagram for updated Git segment with dirty countclassDiagram
class GitSegment {
+show_sha: bool
+show_dirty_count: bool
+new() GitSegment
+with_sha(show_sha: bool) GitSegment
+with_dirty_count(show_dirty_count: bool) GitSegment
+get_git_info(working_dir: &str) Option<GitInfo>
+is_git_repository(working_dir: &str) bool
+get_branch(working_dir: &str) Option<String>
+get_status(working_dir: &str) (GitStatus, u32)
+get_commit_count(working_dir: &str, range: &str) u32
+get_sha(working_dir: &str) Option<String>
}
class GitInfo {
+branch: String
+status: GitStatus
+ahead: u32
+behind: u32
+sha: Option<String>
+dirty_count: u32
}
GitSegment --> GitInfo : returns
Class diagram for threshold_utils and color_utils modulesclassDiagram
class threshold_utils {
+get_thresholds_for_segment(segment_id: SegmentId) Option<(f64, f64)>
+get_color_for_utilization(segment_id: SegmentId, utilization: f64) Option<AnsiColor>
+should_be_bold(segment_id: SegmentId, utilization: f64) Option<bool>
+invalidate_config_cache()
}
class color_utils {
+serialize_ansi_color_to_json(color: &AnsiColor) String
+c16_to_ratatui_color(c16: u8) Color
+ansi_color_to_ratatui(color: &AnsiColor) Color
}
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- There’s a lot of duplicated theme code for the new usage segments across all theme files—consider extracting a helper or macro so you don’t have to copy/paste the same logic nine times.
- The new threshold_utils reads and caches the on-disk config, which won’t reflect changes made in the interactive TUI’s in-memory Config; consider feeding the live config into your threshold logic instead of using a static file cache.
- Mapping every FieldSelection variant to hardcoded indices in App is getting brittle—think about driving that from a data structure or generating it so you avoid off-by-one errors as you add more options.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There’s a lot of duplicated theme code for the new usage segments across all theme files—consider extracting a helper or macro so you don’t have to copy/paste the same logic nine times.
- The new threshold_utils reads and caches the on-disk config, which won’t reflect changes made in the interactive TUI’s in-memory Config; consider feeding the live config into your threshold logic instead of using a static file cache.
- Mapping every FieldSelection variant to hardcoded indices in App is getting brittle—think about driving that from a data structure or generating it so you avoid off-by-one errors as you add more options.
## Individual Comments
### Comment 1
<location> `src/core/segments/color_utils.rs:5` </location>
<code_context>
+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 } => {
</code_context>
<issue_to_address>
**suggestion (performance):** Serializing color to JSON string may be less efficient than storing as Value.
If possible, store the color directly as a serde_json::Value in metadata to reduce parsing overhead and simplify the code.
Suggested implementation:
```rust
/// Serializes an AnsiColor to a serde_json::Value for metadata storage
pub fn serialize_ansi_color_to_json_value(color: &AnsiColor) -> serde_json::Value {
match color {
AnsiColor::Color256 { c256 } => {
serde_json::json!({"c256": c256})
}
AnsiColor::Color16 { c16 } => {
serde_json::json!({"c16": c16})
}
AnsiColor::Rgb { r, g, b } => {
serde_json::json!({"r": r, "g": g, "b": b})
}
}
}
```
- You will need to update any code that calls `serialize_ansi_color_to_json` to use the new function name `serialize_ansi_color_to_json_value` and handle a `serde_json::Value` instead of a `String`.
- If you use this value in metadata, ensure the metadata field expects a `serde_json::Value`.
</issue_to_address>
### Comment 2
<location> `src/core/segments/git.rs:124` </location>
<code_context>
Ok(output) if output.status.success() => {
let status_text = String::from_utf8(output.stdout).unwrap_or_default();
</code_context>
<issue_to_address>
**suggestion:** Parsing git status output may miss edge cases for dirty files.
Consider filtering lines by status code or using --untracked-files=normal to ensure only relevant dirty files are counted.
Suggested implementation:
```rust
let output = Command::new("git")
.args([
"--no-optional-locks",
"status",
"--porcelain",
"--untracked-files=normal",
])
.current_dir(working_dir)
.output();
```
```rust
let status_text = String::from_utf8(output.stdout).unwrap_or_default();
```
```rust
// Count dirty files by filtering lines with relevant status codes
let dirty_count = status_text
.lines()
.filter(|line| {
// Porcelain format: first two chars are status codes
// Untracked files: "??", others: any non-space in first or second char
line.len() >= 2 && (line.starts_with("??") || line[..2].chars().any(|c| c != ' '))
})
.count() as u32;
```
You will need to use `dirty_count` in place of any previous dirty file counting logic in the rest of the function. If the function currently returns a dirty count, update the return statement to use this new `dirty_count` variable.
</issue_to_address>
### Comment 3
<location> `src/core/segments/usage.rs:36` </location>
<code_context>
Self
}
- fn get_circle_icon(utilization: f64) -> String {
+ pub fn get_circle_icon(utilization: f64) -> String {
let percent = (utilization * 100.0) as u8;
</code_context>
<issue_to_address>
**nitpick:** get_circle_icon's percent calculation may round down for values near boundaries.
Using .round() before casting will improve accuracy for icon selection.
</issue_to_address>
### Comment 4
<location> `src/core/segments/usage_5hour.rs:20-27` </location>
<code_context>
+ let reset_time = UsageSegment::format_5hour_reset_time(cache.five_hour_resets_at.as_deref());
+
+ // Convert percentage (0-100) to normalized value (0-1) for get_circle_icon
+ let dynamic_icon = UsageSegment::get_circle_icon(five_hour_util / 100.0);
+
+ let five_hour_percent = five_hour_util.round() as u8;
</code_context>
<issue_to_address>
**suggestion:** Division by 100.0 assumes API always returns 0-100.
Clamping or validating the input before division will prevent incorrect icon selection if the API returns unexpected values.
```suggestion
// Note: five_hour_utilization is a percentage (0-100) from the API
let five_hour_util = cache.five_hour_utilization;
let reset_time = UsageSegment::format_5hour_reset_time(cache.five_hour_resets_at.as_deref());
// Clamp the value to [0.0, 100.0] to prevent incorrect icon selection
let clamped_util = five_hour_util.clamp(0.0, 100.0);
// Convert percentage (0-100) to normalized value (0-1) for get_circle_icon
let dynamic_icon = UsageSegment::get_circle_icon(clamped_util / 100.0);
let five_hour_percent = clamped_util.round() as u8;
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
src/core/segments/git.rs
Outdated
| || status_text.contains("AA") | ||
| || status_text.contains("DD") | ||
| { | ||
| GitStatus::Conflicts |
There was a problem hiding this comment.
suggestion: Parsing git status output may miss edge cases for dirty files.
Consider filtering lines by status code or using --untracked-files=normal to ensure only relevant dirty files are counted.
Suggested implementation:
let output = Command::new("git")
.args([
"--no-optional-locks",
"status",
"--porcelain",
"--untracked-files=normal",
])
.current_dir(working_dir)
.output(); let status_text = String::from_utf8(output.stdout).unwrap_or_default(); // Count dirty files by filtering lines with relevant status codes
let dirty_count = status_text
.lines()
.filter(|line| {
// Porcelain format: first two chars are status codes
// Untracked files: "??", others: any non-space in first or second char
line.len() >= 2 && (line.starts_with("??") || line[..2].chars().any(|c| c != ' '))
})
.count() as u32;You will need to use dirty_count in place of any previous dirty file counting logic in the rest of the function. If the function currently returns a dirty count, update the return statement to use this new dirty_count variable.
src/core/segments/usage.rs
Outdated
| Self | ||
| } | ||
|
|
||
| fn get_circle_icon(utilization: f64) -> String { |
There was a problem hiding this comment.
nitpick: get_circle_icon's percent calculation may round down for values near boundaries.
Using .round() before casting will improve accuracy for icon selection.
1afab9d to
f36d76a
Compare
Summary
Fixes #46
Adds the
--no-optional-locksflag to all git command invocations in the Git segment to prevent creation of.git/index.lockfiles during statusline operations. This eliminates potential conflicts with concurrent user git operations.Changes
--no-optional-lockstois_git_repository()- git rev-parse command--no-optional-lockstoget_branch()- git branch and git symbolic-ref commands--no-optional-lockstoget_status()- git status command (most critical)--no-optional-lockstoget_commit_count()- git rev-list command--no-optional-lockstoget_sha()- git rev-parse commandBenefits
Test plan
cargo build.git/index.lockfiles are created during statusline updates🤖 Generated with Claude Code
Summary by Sourcery
Add
--no-optional-locksto all Git invocations to prevent lock file creation and introduce two new focused usage segments with dynamic threshold‐based coloring and styling. Update TUI components, themes, and core utilities to support new Usage5Hour and Usage7Day segments, threshold configuration, Git segment options (show SHA and dirty count), and unified color conversion. Bump version to 1.0.9 and refresh documentation and changelog accordingly.New Features:
Enhancements:
Documentation:
Chores: