From 09df4208934040a21a7ecbb391f95734b6ea2e4c Mon Sep 17 00:00:00 2001 From: Quinn Slack Date: Wed, 3 Jul 2024 03:39:08 -0700 Subject: [PATCH] remove autocomplete limit from Cody dashboard page (#63609) Now it always shows "N / unlimited" to all users. For Cody Free users, it no longer shows a limit. For Cody Pro users, it now shows the actual number of autocompletes they've done this month. ![image](https://github.com/sourcegraph/sourcegraph/assets/1976/5047b5a6-a804-437a-8eb0-9155bc67fc38) ## Test plan View page and ensure it shows correctly. --- .../src/cody/management/SubscriptionStats.tsx | 37 ++++--------------- client/web/src/cody/subscription/queries.tsx | 1 - cmd/frontend/graphqlbackend/user.go | 2 + 3 files changed, 9 insertions(+), 31 deletions(-) diff --git a/client/web/src/cody/management/SubscriptionStats.tsx b/client/web/src/cody/management/SubscriptionStats.tsx index 1e8cb5c7c41..d7afbb3818b 100644 --- a/client/web/src/cody/management/SubscriptionStats.tsx +++ b/client/web/src/cody/management/SubscriptionStats.tsx @@ -33,10 +33,8 @@ export const SubscriptionStats: React.FunctionComponent const stats = usageData?.currentUser const codyCurrentPeriodChatLimit = stats?.codyCurrentPeriodChatLimit || 0 const codyCurrentPeriodChatUsage = stats?.codyCurrentPeriodChatUsage || 0 - const codyCurrentPeriodCodeLimit = stats?.codyCurrentPeriodCodeLimit || 0 const codyCurrentPeriodCodeUsage = stats?.codyCurrentPeriodCodeUsage || 0 - const codeLimitReached = codyCurrentPeriodCodeUsage >= codyCurrentPeriodCodeLimit && codyCurrentPeriodCodeLimit > 0 const chatLimitReached = codyCurrentPeriodChatUsage >= codyCurrentPeriodChatLimit && codyCurrentPeriodChatLimit > 0 const isUserOnProTier = subscription.plan === CodySubscriptionPlan.PRO @@ -84,40 +82,19 @@ export const SubscriptionStats: React.FunctionComponent
- {subscription.applyProRateLimits ? ( - - Unlimited - - ) : usageData?.currentUser ? ( + {usageData?.currentUser ? ( <> - - {Math.min(codyCurrentPeriodCodeUsage, codyCurrentPeriodCodeLimit)} / - {' '} - - {codyCurrentPeriodCodeLimit} - + {codyCurrentPeriodCodeUsage} /{' '} + unlimited ) : ( )}
-

- Autocomplete suggestions -

- {!subscription.applyProRateLimits && - (codeLimitReached ? ( - - Renews in - - ) : ( - - this month - - ))} +

Autocomplete suggestions

+ + this month +
diff --git a/client/web/src/cody/subscription/queries.tsx b/client/web/src/cody/subscription/queries.tsx index 6965498ba0a..0285cabe234 100644 --- a/client/web/src/cody/subscription/queries.tsx +++ b/client/web/src/cody/subscription/queries.tsx @@ -23,7 +23,6 @@ export const USER_CODY_USAGE = gql` codyCurrentPeriodChatUsage codyCurrentPeriodCodeUsage codyCurrentPeriodChatLimit - codyCurrentPeriodCodeLimit codySubscription { status plan diff --git a/cmd/frontend/graphqlbackend/user.go b/cmd/frontend/graphqlbackend/user.go index 108d6a0212a..c18e3cf9e06 100644 --- a/cmd/frontend/graphqlbackend/user.go +++ b/cmd/frontend/graphqlbackend/user.go @@ -279,6 +279,8 @@ func (r *UserResolver) CodyCurrentPeriodCodeLimit(ctx context.Context) (int32, e return 0, errors.New("this feature is only available on sourcegraph.com") } + // TODO(sqs): This is not enforced anymore as the intent is to give free unlimited autocomplete. + subscription, err := r.fetchCodySubscription(ctx) if err != nil { return 0, err