Skip to content

Commit 0d7f29a

Browse files
committed
fix: address CLI agent review feedback for referral migration
- Remove "per month" language from web banner.tsx (now uses "bonus credits") - Move getTypesInBucket helper to module level in usage-display.tsx - Update CLI referral.ts messaging: "per referral" → "for each referral" Verified by Claude Code, Codex, and Gemini CLI agents.
1 parent b2b663e commit 0d7f29a

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

cli/src/commands/referral.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export async function handleReferralCode(referralCode: string): Promise<{
5151
...prev,
5252
getSystemMessage(
5353
`🎉 Noice, you've earned ${creditsRedeemed} bonus credits!\n\n` +
54-
`(pssst: you can also refer new users and earn ${CREDITS_REFERRAL_BONUS} credits per referral at: ${env.NEXT_PUBLIC_CODEBUFF_APP_URL}/referrals)`,
54+
`(pssst: you can also refer new users and earn ${CREDITS_REFERRAL_BONUS} bonus credits for each referral at: ${env.NEXT_PUBLIC_CODEBUFF_APP_URL}/referrals)`,
5555
),
5656
]
5757
return { postUserMessage }

web/src/app/profile/components/usage-display.tsx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,26 @@ const grantTypeInfo: Record<
8686
},
8787
}
8888

89+
/**
90+
* Helper to get grant types with non-zero balance or principal in a bucket.
91+
* Defined at module level to avoid recreation on each render.
92+
*/
93+
function getTypesInBucket(
94+
bucket: CreditExpirationBucket,
95+
principalsByExpiration: Record<CreditExpirationBucket, Record<GrantType, number>>,
96+
breakdownByExpiration: Record<CreditExpirationBucket, Record<GrantType, number>>,
97+
): FilteredGrantType[] {
98+
const types: FilteredGrantType[] = []
99+
for (const type of Object.keys(grantTypeInfo) as FilteredGrantType[]) {
100+
const principal = principalsByExpiration[bucket][type] || 0
101+
const remaining = breakdownByExpiration[bucket][type] || 0
102+
if (principal > 0 || remaining > 0) {
103+
types.push(type)
104+
}
105+
}
106+
return types
107+
}
108+
89109
interface CreditLeafProps {
90110
type: FilteredGrantType
91111
amount: number
@@ -231,21 +251,8 @@ export const UsageDisplay = ({
231251
// Get expiration buckets from balance (data-driven, not hardcoded)
232252
const { breakdownByExpiration, principalsByExpiration } = balance
233253

234-
// Helper to get types with non-zero balance or principal in a bucket
235-
const getTypesInBucket = (bucket: CreditExpirationBucket): FilteredGrantType[] => {
236-
const types: FilteredGrantType[] = []
237-
for (const type of Object.keys(grantTypeInfo) as FilteredGrantType[]) {
238-
const principal = principalsByExpiration[bucket][type] || 0
239-
const remaining = breakdownByExpiration[bucket][type] || 0
240-
if (principal > 0 || remaining > 0) {
241-
types.push(type)
242-
}
243-
}
244-
return types
245-
}
246-
247-
const renewableTypes = getTypesInBucket('renewable')
248-
const nonRenewableTypes = getTypesInBucket('nonRenewable')
254+
const renewableTypes = getTypesInBucket('renewable', principalsByExpiration, breakdownByExpiration)
255+
const nonRenewableTypes = getTypesInBucket('nonRenewable', principalsByExpiration, breakdownByExpiration)
249256

250257
const expiringTotal = renewableTypes.reduce(
251258
(acc, type) => acc + (principalsByExpiration.renewable[type] || 0),

web/src/components/ui/banner.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ function BannerContent() {
4343
<p className="text-sm md:whitespace-nowrap">
4444
{isPersonalReferral ? (
4545
<>
46-
{capitalize(referrer)} got you an extra {CREDITS_REFERRAL_BONUS}{' '}
47-
credits per month!
46+
{capitalize(referrer)} got you {CREDITS_REFERRAL_BONUS}{' '}
47+
bonus credits!
4848
</>
4949
) : (
5050
<>
51-
Refer a friend, and earn {CREDITS_REFERRAL_BONUS} credits per
52-
month for both of you!
51+
Refer a friend, and you'll both earn {CREDITS_REFERRAL_BONUS}{' '}
52+
bonus credits!
5353
</>
5454
)}{' '}
5555
<Link

0 commit comments

Comments
 (0)