From e7f4558f0194d05950c36cf3f47e36fca02055dc Mon Sep 17 00:00:00 2001 From: Marcio Granzotto Rodrigues Date: Fri, 12 Jun 2026 10:44:40 -0300 Subject: [PATCH] feat(rate-limits): add optional progress bars for 5h/7d usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds RATE_SHOW_PROGRESS_BAR (default: false) to render a visual bar between the label and percentage, e.g. "5h:███░░░░░ 45%", matching the context module's bar style. RATE_PROGRESS_BAR_WIDTH overrides the global PROGRESS_BAR_WIDTH for this module only. Co-Authored-By: Claude Fable 5 --- barista.conf | 6 ++++++ modules/rate-limits.sh | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/barista.conf b/barista.conf index 57ac8f7..2897b70 100644 --- a/barista.conf +++ b/barista.conf @@ -276,6 +276,12 @@ RATE_SHOW_TIME_REMAINING="true" # Show projection status indicator (colored dot predicting if you'll hit limit) RATE_SHOW_PROJECTION="true" +# Show visual progress bar before each percentage (e.g., "5h:███░░░░░ 45%") +RATE_SHOW_PROGRESS_BAR="false" + +# Progress bar width (empty = use global PROGRESS_BAR_WIDTH) +RATE_PROGRESS_BAR_WIDTH="" + # Threshold percentages for status colors RATE_WARNING_THRESHOLD=80 # Yellow at this percentage RATE_CRITICAL_THRESHOLD=100 # Red at this percentage diff --git a/modules/rate-limits.sh b/modules/rate-limits.sh index 13ac3ce..af1d44e 100644 --- a/modules/rate-limits.sh +++ b/modules/rate-limits.sh @@ -9,6 +9,8 @@ # RATE_SHOW_TIME_REMAINING - Show time until reset (default: true) # RATE_SHOW_PROJECTION - Show projection status (default: true) # RATE_SHOW_USAGE_STATUS - Show usage level indicator (default: true) +# RATE_SHOW_PROGRESS_BAR - Show visual progress bar (default: false) +# RATE_PROGRESS_BAR_WIDTH - Progress bar width (default: PROGRESS_BAR_WIDTH) # RATE_LOW_THRESHOLD - Green/yellow boundary (default: 50) # RATE_MEDIUM_THRESHOLD - Yellow/orange boundary (default: 75) # RATE_HIGH_THRESHOLD - Orange/red boundary (default: 95) @@ -197,6 +199,8 @@ module_rate_limits() { local show_7d="${RATE_SHOW_7D:-true}" local show_time="${RATE_SHOW_TIME_REMAINING:-true}" local show_usage_status="${RATE_SHOW_USAGE_STATUS:-true}" + local show_bar="${RATE_SHOW_PROGRESS_BAR:-false}" + local bar_width="${RATE_PROGRESS_BAR_WIDTH:-}" local compact="${RATE_COMPACT:-false}" local label_5h="${RATE_5H_LABEL:-5h}" local label_7d="${RATE_7D_LABEL:-7d}" @@ -401,15 +405,23 @@ module_rate_limits() { stale_marker=" $(get_icon '⏸' 'WAIT')${cooldown_display}" fi + # Optional progress bars (rendered between label and percentage) + local five_hour_bar="" + local seven_day_bar="" + if [ "$show_bar" = "true" ]; then + five_hour_bar="$(progress_bar "$five_hour_int" "$bar_width") " + seven_day_bar="$(progress_bar "$seven_day_int" "$bar_width") " + fi + if [ "$show_5h" = "true" ]; then - result="${label_5h}:${five_hour_int}% ${five_hour_usage_ind}${five_hour_status}" + result="${label_5h}:${five_hour_bar}${five_hour_int}% ${five_hour_usage_ind}${five_hour_status}" if [ "$show_time" = "true" ] && [ "$five_hour_remaining" -gt 0 ] 2>/dev/null && ! is_compact "$compact"; then result="${result} ($(format_time_remaining $five_hour_remaining))" fi fi if [ "$show_7d" = "true" ]; then - local seven_day_part="${label_7d}:${seven_day_int}% ${seven_day_usage_ind}${seven_day_status}" + local seven_day_part="${label_7d}:${seven_day_bar}${seven_day_int}% ${seven_day_usage_ind}${seven_day_status}" if [ "$show_time" = "true" ] && [ "$seven_day_remaining" -gt 0 ] 2>/dev/null && ! is_compact "$compact"; then seven_day_part="${seven_day_part} ($(format_time_remaining $seven_day_remaining))" fi