From 442b8637fb006fa3f6eed261dbb15b66dc4eebc5 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 20 Jan 2025 15:16:50 -0800 Subject: [PATCH] free trial logic fixes --- core/config/onboarding.ts | 2 +- extensions/vscode/package-lock.json | 4 ++-- gui/src/components/Layout.tsx | 6 +----- gui/src/pages/gui/Chat.tsx | 27 ++++++++++++--------------- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/core/config/onboarding.ts b/core/config/onboarding.ts index 426a7a4ba..f0a506fdf 100644 --- a/core/config/onboarding.ts +++ b/core/config/onboarding.ts @@ -9,7 +9,7 @@ export const LOCAL_ONBOARDING_CHAT_MODEL = "llama3.1:8b"; export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B"; /** - * We set the "best" chat + autocopmlete models by default + * We set the "best" chat + autocomplete models by default * whenever a user doesn't have a config.json */ export function setupBestConfig( diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 31f06cbb1..cf132e7ba 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.252", + "version": "0.9.253", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.252", + "version": "0.9.253", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index e8a0deb12..b4fb5fd8a 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -151,11 +151,7 @@ const Layout = () => { "incrementFtc", async () => { const u = getLocalStorage("ftc"); - if (u) { - setLocalStorage("ftc", u + 1); - } else { - setLocalStorage("ftc", 1); - } + setLocalStorage("ftc", (u ?? 0) + 1); }, [], ); diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 3f36adcef..49a4b5f31 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -247,21 +247,18 @@ export function Chat() { editorToClearOnSend?: Editor, ) => { if (defaultModel?.provider === "free-trial") { - const u = getLocalStorage("ftc"); - if (u) { - setLocalStorage("ftc", u + 1); - - if (u >= FREE_TRIAL_LIMIT_REQUESTS) { - onboardingCard.open("Best"); - posthog?.capture("ftc_reached"); - ideMessenger.ide.showToast( - "info", - "You've reached the free trial limit. Please configure a model to continue.", - ); - return; - } - } else { - setLocalStorage("ftc", 1); + const u = getLocalStorage("ftc") ?? 0; + setLocalStorage("ftc", u + 1); + if (u === FREE_TRIAL_LIMIT_REQUESTS) { + posthog?.capture("ftc_reached"); + } + if (u >= FREE_TRIAL_LIMIT_REQUESTS) { + onboardingCard.open("Best"); + ideMessenger.ide.showToast( + "info", + "You've reached the free trial limit. Please configure a model to continue.", + ); + return; } }