From bbc2739832b9bf17f228fa3f6ade83625f1694bd Mon Sep 17 00:00:00 2001 From: "Thomas G. Lopes" <26071571+TGlide@users.noreply.github.com> Date: Thu, 19 Jun 2025 13:11:48 +0100 Subject: [PATCH] free mode wip --- README.md | 2 +- src/lib/backend/convex/user_enabled_models.ts | 38 +++++++++++++++++++ src/routes/account/customization/rule.svelte | 32 ++++++++-------- src/routes/chat/+layout.svelte | 6 +++ 4 files changed, 62 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 6d340bc..6f2bf81 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Clone of [T3 Chat](https://t3.chat/) ### Final push -- [ ] Private mode for greeting +- [x] Private mode for greeting - [ ] Free mode - [ ] make things prettier - [ ] mobile adjustments diff --git a/src/lib/backend/convex/user_enabled_models.ts b/src/lib/backend/convex/user_enabled_models.ts index 44298c3..60d6c72 100644 --- a/src/lib/backend/convex/user_enabled_models.ts +++ b/src/lib/backend/convex/user_enabled_models.ts @@ -114,3 +114,41 @@ export const set = mutation({ } }, }); + +export const enable_initial = mutation({ + args: { + session_token: v.string(), + }, + handler: async (ctx, args) => { + const session = await ctx.runQuery(internal.betterAuth.getSession, { + sessionToken: args.session_token, + }); + + if (!session) { + throw new Error('Unauthorized'); + } + + // Check if any models are enabled + const enabledModels = await ctx.db + .query('user_enabled_models') + .withIndex('by_user', (q) => q.eq('user_id', session.userId)) + .collect(); + + if (enabledModels.length > 0) { + return; + } + + const initialModels = ['google/gemini-2.5-flash', 'deepseek/deepseek-chat-v3-0324:free']; + + await Promise.all( + initialModels.map((model) => + ctx.db.insert('user_enabled_models', { + user_id: session.userId, + provider: Provider.OpenRouter, + model_id: model, + pinned: null, + }) + ) + ); + }, +}); diff --git a/src/routes/account/customization/rule.svelte b/src/routes/account/customization/rule.svelte index 153abaf..d2983c0 100644 --- a/src/routes/account/customization/rule.svelte +++ b/src/routes/account/customization/rule.svelte @@ -81,11 +81,7 @@ let ruleName = $derived(rule.name); - let renaming = $state(false); - async function renameRule() { - renaming = true; - await ResultAsync.fromPromise( client.mutation(api.user_rules.rename, { ruleId: rule._id, @@ -94,8 +90,6 @@ }), (e) => e ); - - renaming = false; } const ruleNameExists = $derived.by(() => { @@ -111,15 +105,23 @@
-
- - +
+ +
+ + +