MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / getThresholdInfo

Function getThresholdInfo

cli/src/utils/usage-banner-state.ts:19–49  ·  view source on GitHub ↗
(balance: number | null)

Source from the content-addressed store, hash-verified

17 * This is the single source of truth for credit tier classification.
18 */
19export function getThresholdInfo(balance: number | null): ThresholdInfo {
20 if (balance === null) {
21 return {
22 tier: 'medium',
23 colorLevel: 'warning',
24 threshold: MEDIUM_CREDITS_THRESHOLD,
25 }
26 }
27 if (balance >= HIGH_CREDITS_THRESHOLD) {
28 return {
29 tier: 'high',
30 colorLevel: 'success',
31 threshold: HIGH_CREDITS_THRESHOLD,
32 }
33 }
34 if (balance >= MEDIUM_CREDITS_THRESHOLD) {
35 return {
36 tier: 'medium',
37 colorLevel: 'warning',
38 threshold: MEDIUM_CREDITS_THRESHOLD,
39 }
40 }
41 if (balance >= LOW_CREDITS_THRESHOLD) {
42 return {
43 tier: 'low',
44 colorLevel: 'warning',
45 threshold: LOW_CREDITS_THRESHOLD,
46 }
47 }
48 return { tier: 'out', colorLevel: 'error', threshold: 0 }
49}
50
51/**
52 * Determines the appropriate color level for the usage banner based on credit balance.

Callers 2

getBannerColorLevelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected