mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-27 21:08:00 +00:00
fix(billing): hide budget-complete prompt for free zero-budget plans (#2300)
This commit is contained in:
@@ -114,7 +114,7 @@ describe('useUsageState', () => {
|
||||
mockLoadAISettings.mockResolvedValue(ALL_OPENHUMAN_AI_SETTINGS);
|
||||
});
|
||||
|
||||
it('does not treat free users with zero recurring budget as exhausted', async () => {
|
||||
it('does not show the completed-budget message for free users with zero recurring budget', async () => {
|
||||
const { useUsageState } = await import('./useUsageState');
|
||||
mockGetCurrentPlan.mockResolvedValue(freePlan());
|
||||
mockGetTeamUsage.mockResolvedValue(buildUsage());
|
||||
@@ -127,7 +127,7 @@ describe('useUsageState', () => {
|
||||
|
||||
expect(result.current.isFreeTier).toBe(true);
|
||||
expect(result.current.isBudgetExhausted).toBe(false);
|
||||
expect(result.current.shouldShowBudgetCompletedMessage).toBe(true);
|
||||
expect(result.current.shouldShowBudgetCompletedMessage).toBe(false);
|
||||
expect(result.current.isAtLimit).toBe(false);
|
||||
expect(result.current.usagePct).toBe(0);
|
||||
});
|
||||
|
||||
@@ -165,12 +165,10 @@ export function useUsageState(): UsageState {
|
||||
? teamUsage.cycleBudgetUsd > 0.01 && teamUsage.remainingUsd <= 0.01
|
||||
: false;
|
||||
|
||||
// Some users have no included recurring budget at all. They still need the
|
||||
// completed-budget warning in chat even though they are not in an exhausted
|
||||
// paid cycle — but only when their chat actually flows through OpenHuman.
|
||||
const rawShouldShowBudgetCompletedMessage = teamUsage
|
||||
? rawBudgetExhausted || (teamUsage.cycleBudgetUsd <= 0.01 && teamUsage.remainingUsd <= 0.01)
|
||||
: false;
|
||||
// Only show the completed-budget warning for an actually exhausted
|
||||
// recurring budget. Free plans with no recurring budget should not look like
|
||||
// they have exhausted a paid/included cycle (#2129).
|
||||
const rawShouldShowBudgetCompletedMessage = rawBudgetExhausted;
|
||||
|
||||
const isBudgetExhausted = !isFullyRoutedAway && rawBudgetExhausted;
|
||||
const shouldShowBudgetCompletedMessage =
|
||||
|
||||
Reference in New Issue
Block a user