-
Notifications
You must be signed in to change notification settings - Fork 518
Expand file tree
/
Copy pathbottom-status-line.tsx
More file actions
82 lines (71 loc) · 2.31 KB
/
bottom-status-line.tsx
File metadata and controls
82 lines (71 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import React from 'react'
import { useTheme } from '../hooks/use-theme'
import { formatResetTime } from '../utils/time-format'
import type { ClaudeQuotaData } from '../hooks/use-claude-quota-query'
interface BottomStatusLineProps {
/** Whether Claude OAuth is connected */
isClaudeConnected: boolean
/** Whether Claude is actively being used (streaming/waiting) */
isClaudeActive: boolean
/** Quota data from Anthropic API */
claudeQuota?: ClaudeQuotaData | null
}
/**
* Bottom status line component - shows below the input box
* Currently displays Claude subscription status when connected
*/
export const BottomStatusLine: React.FC<BottomStatusLineProps> = ({
isClaudeConnected,
isClaudeActive,
claudeQuota,
}) => {
const theme = useTheme()
// Don't render if there's nothing to show
if (!isClaudeConnected) {
return null
}
// Use the more restrictive of the two quotas (5-hour window is usually the limiting factor)
const displayRemaining = claudeQuota
? Math.min(claudeQuota.fiveHourRemaining, claudeQuota.sevenDayRemaining)
: null
// Check if quota is exhausted (0%)
const isExhausted = displayRemaining !== null && displayRemaining <= 0
// Get the reset time for the limiting quota window
const resetTime = claudeQuota
? claudeQuota.fiveHourRemaining <= claudeQuota.sevenDayRemaining
? claudeQuota.fiveHourResetsAt
: claudeQuota.sevenDayResetsAt
: null
// Determine dot color: red if exhausted, green if active, muted otherwise
const dotColor = isExhausted
? theme.error
: isClaudeActive
? theme.success
: theme.muted
return (
<box
style={{
width: '100%',
flexDirection: 'row',
justifyContent: 'flex-end',
paddingRight: 1,
}}
>
<box
style={{
flexDirection: 'row',
alignItems: 'center',
gap: 0,
}}
>
<text style={{ fg: dotColor }}>●</text>
<text style={{ fg: theme.muted }}> Claude subscription</text>
{isExhausted && resetTime ? (
<text style={{ fg: theme.muted }}>{` · resets in ${formatResetTime(resetTime)}`}</text>
) : displayRemaining !== null ? (
<text style={{ fg: theme.foreground }}>{` ${Math.round(displayRemaining)}%`}</text>
) : null}
</box>
</box>
)
}