11import { isClaudeOAuthValid } from '@codebuff/sdk'
22import open from 'open'
3- import React , { useEffect , useMemo } from 'react'
3+ import React , { useEffect , useMemo , useState } from 'react'
44
55import { BottomBanner } from './bottom-banner'
66import { Button } from './button'
@@ -11,6 +11,7 @@ import { useSubscriptionQuery } from '../hooks/use-subscription-query'
1111import { useTheme } from '../hooks/use-theme'
1212import { usageQueryKeys , useUsageQuery } from '../hooks/use-usage-query'
1313import { WEBSITE_URL } from '../login/constants'
14+ import { getAlwaysUseALaCarte , setAlwaysUseALaCarte } from '../utils/settings'
1415import { useChatStore } from '../state/chat-store'
1516import { formatResetTime , formatResetTimeLong } from '../utils/time-format'
1617import {
@@ -216,6 +217,13 @@ const SubscriptionUsageSection: React.FC<SubscriptionUsageSectionProps> = ({
216217 isLoading,
217218} ) => {
218219 const theme = useTheme ( )
220+ const [ useALaCarte , setUseALaCarte ] = useState ( ( ) => getAlwaysUseALaCarte ( ) )
221+
222+ const handleToggleALaCarte = ( ) => {
223+ const newValue = ! useALaCarte
224+ setUseALaCarte ( newValue )
225+ setAlwaysUseALaCarte ( newValue )
226+ }
219227
220228 const blockPercent = useMemo ( ( ) => {
221229 if ( rateLimit ?. blockLimit == null || rateLimit . blockUsed == null ) return 100
@@ -258,6 +266,17 @@ const SubscriptionUsageSection: React.FC<SubscriptionUsageSectionProps> = ({
258266 </ box >
259267 </ box >
260268 ) : null }
269+ < box style = { { flexDirection : 'row' , alignItems : 'center' , gap : 1 , marginTop : 1 } } >
270+ < text style = { { fg : theme . muted } } > When limit reached:</ text >
271+ < text style = { { fg : theme . muted } } >
272+ { useALaCarte ? 'spend credits' : 'pause' }
273+ </ text >
274+ < Button onClick = { handleToggleALaCarte } >
275+ < text style = { { fg : theme . muted } } >
276+ [{ useALaCarte ? 'switch to pause' : 'switch to spend credits' } ]
277+ </ text >
278+ </ Button >
279+ </ box >
261280 </ box >
262281 )
263282}
0 commit comments