MCPcopy
hub / github.com/CodebuffAI/codebuff / CreditsOrSubscriptionIndicator

Function CreditsOrSubscriptionIndicator

cli/src/components/message-footer.tsx:221–258  ·  view source on GitHub ↗
({ credits })

Source from the content-addressed store, hash-verified

219}
220
221const CreditsOrSubscriptionIndicator: React.FC<{ credits: number }> = ({ credits }) => {
222 const theme = useTheme()
223 const { data: subscriptionData } = useSubscriptionQuery({
224 refetchInterval: false,
225 refetchOnActivity: false,
226 pauseWhenIdle: false,
227 })
228
229 const blockPercentRemaining = useMemo(
230 () => getBlockPercentRemaining(subscriptionData),
231 [subscriptionData],
232 )
233
234 const showSubscriptionIndicator = isCoveredBySubscription(subscriptionData)
235
236 if (showSubscriptionIndicator) {
237 const label = (blockPercentRemaining ?? 0) < 20
238 ? `✓ ${SUBSCRIPTION_DISPLAY_NAME} (${blockPercentRemaining}% left)`
239 : `✓ ${SUBSCRIPTION_DISPLAY_NAME}`
240 return (
241 <text
242 attributes={TextAttributes.DIM}
243 style={{ wrapMode: 'none', fg: theme.success, marginTop: 0, marginBottom: 0 }}
244 >
245 {label}
246 </text>
247 )
248 }
249
250 return (
251 <text
252 attributes={TextAttributes.DIM}
253 style={{ wrapMode: 'none', fg: theme.secondary, marginTop: 0, marginBottom: 0 }}
254 >
255 {pluralize(credits, 'credit')}
256 </text>
257 )
258}

Callers

nothing calls this directly

Calls 5

useThemeFunction · 0.90
useSubscriptionQueryFunction · 0.90
getBlockPercentRemainingFunction · 0.90
isCoveredBySubscriptionFunction · 0.90
pluralizeFunction · 0.90

Tested by

no test coverage detected