Skip to content

Commit 4f870f6

Browse files
committed
claude sub: usage bar instead of % in status bar
1 parent 9c41d60 commit 4f870f6

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

cli/src/components/bottom-status-line.tsx

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import React from 'react'
22

33
import { useTheme } from '../hooks/use-theme'
4-
54
import { formatResetTime } from '../utils/time-format'
6-
75
import type { ClaudeQuotaData } from '../hooks/use-claude-quota-query'
86

97
interface BottomStatusLineProps {
@@ -74,18 +72,46 @@ export const BottomStatusLine: React.FC<BottomStatusLineProps> = ({
7472
{isExhausted && resetTime ? (
7573
<text style={{ fg: theme.muted }}>{` · resets in ${formatResetTime(resetTime)}`}</text>
7674
) : displayRemaining !== null ? (
77-
<text
78-
style={{
79-
fg:
80-
displayRemaining <= 10
81-
? theme.error
82-
: displayRemaining <= 25
83-
? theme.warning
84-
: theme.muted,
85-
}}
86-
>{` ${Math.round(displayRemaining)}%`}</text>
75+
<BatteryIndicator value={displayRemaining} theme={theme} />
8776
) : null}
8877
</box>
8978
</box>
9079
)
9180
}
81+
82+
/** Battery indicator width in characters */
83+
const BATTERY_WIDTH = 8
84+
85+
/** Compact battery-style progress indicator for the status line */
86+
const BatteryIndicator: React.FC<{
87+
value: number
88+
theme: { muted: string; warning: string; error: string }
89+
}> = ({ value, theme }) => {
90+
const clampedValue = Math.max(0, Math.min(100, value))
91+
const filledWidth = Math.round((clampedValue / 100) * BATTERY_WIDTH)
92+
const emptyWidth = BATTERY_WIDTH - filledWidth
93+
94+
const filledChar = '█'
95+
const emptyChar = '░'
96+
97+
const filled = filledChar.repeat(filledWidth)
98+
const empty = emptyChar.repeat(emptyWidth)
99+
100+
// Color based on percentage thresholds
101+
// Use muted color for healthy capacity (>25%) to avoid drawing attention,
102+
// warning/error colors only when running low
103+
const barColor =
104+
clampedValue <= 10
105+
? theme.error
106+
: clampedValue <= 25
107+
? theme.warning
108+
: theme.muted
109+
110+
return (
111+
<box style={{ flexDirection: 'row', alignItems: 'center', gap: 0 }}>
112+
<text style={{ fg: theme.muted }}> [</text>
113+
<text style={{ fg: barColor }}>{filled}</text>
114+
<text style={{ fg: theme.muted }}>{empty}]</text>
115+
</box>
116+
)
117+
}

cli/src/components/progress-bar.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ const getProgressColor = (
3232

3333
/**
3434
* Get color for the filled portion of the bar
35+
* Uses muted color for healthy capacity (>25%) to avoid drawing attention,
36+
* warning/error colors only when running low
3537
*/
3638
const getBarColor = (
3739
value: number,
38-
theme: { primary: string; warning: string; error: string },
40+
theme: { muted: string; warning: string; error: string },
3941
): string => {
4042
if (value <= 10) return theme.error
4143
if (value <= 25) return theme.warning
42-
return theme.primary // Use primary for the bar itself
44+
return theme.muted
4345
}
4446

4547
/**

0 commit comments

Comments
 (0)