Skip to content

Commit b05bd84

Browse files
added new models
1 parent a52865e commit b05bd84

File tree

6 files changed

+41
-43
lines changed

6 files changed

+41
-43
lines changed

app/actions/profile.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { createServerClient, type CookieOptions } from "@supabase/ssr"
44
import { cookies } from "next/headers"
55
import { revalidatePath } from "next/cache"
66

7-
// Matches the ProfileFormData in app/settings/profile/page.tsx and Supabase table
87
export interface ProfileData {
9-
id?: string // User ID from auth.users
8+
id?: string
109
first_name: string | null
1110
last_name: string | null
1211
company: string | null
@@ -19,8 +18,7 @@ export interface ProfileData {
1918
personalized_responses: boolean
2019
activity_status: boolean
2120
profile_visibility: "public" | "private" | "contacts"
22-
avatar_url?: string | null // For profile picture
23-
// email will be fetched from auth.user if needed, not stored directly here for update
21+
avatar_url?: string | null
2422
}
2523

2624
export async function getProfile(): Promise<ProfileData | null> {
@@ -39,8 +37,6 @@ export async function getProfile(): Promise<ProfileData | null> {
3937
const cookieStore = await cookieStorePromise
4038
cookieStore.set(name, value, options)
4139
} catch (error) {
42-
// If the set method is called from a Server Component, an error may occur.
43-
// This can be ignored if you have middleware refreshing user sessions.
4440
console.warn(`Failed to set cookie '${name}' from Server Action/Component. This might be okay if middleware handles session refresh. Error: ${error}`);
4541
}
4642
},
@@ -49,8 +45,6 @@ export async function getProfile(): Promise<ProfileData | null> {
4945
const cookieStore = await cookieStorePromise
5046
cookieStore.delete(name)
5147
} catch (error) {
52-
// If the delete method is called from a Server Component, an error may occur.
53-
// This can be ignored if you have middleware refreshing user sessions.
5448
console.warn(`Failed to delete cookie '${name}' from Server Action/Component. This might be okay if middleware handles session refresh. Error: ${error}`);
5549
}
5650
},
@@ -77,7 +71,6 @@ export async function getProfile(): Promise<ProfileData | null> {
7771
if (error) {
7872
if (error.code === 'PGRST116') { // PGRST116: "Searched for a single row, but 0 rows were found"
7973
console.log("No profile found for user, returning defaults or null.")
80-
// You might want to return a default profile structure or ensure one is created on user signup
8174
return {
8275
id: user.id,
8376
first_name: "",
@@ -145,9 +138,6 @@ export async function updateProfile(
145138
return { success: false, error: "User not authenticated" }
146139
}
147140

148-
// Ensure 'id' is not part of the update payload to Supabase,
149-
// as it's used in the .eq() clause and is the primary key.
150-
// 'updated_at' will be handled by the database trigger.
151141
const { id, ...updateData } = profileData
152142

153143
const { error } = await supabase
@@ -160,8 +150,8 @@ export async function updateProfile(
160150
return { success: false, error }
161151
}
162152

163-
revalidatePath("/settings/profile") // Revalidate the profile page to show updated data
164-
revalidatePath("/") // Revalidate other paths if profile info is displayed elsewhere
153+
revalidatePath("/settings/profile")
154+
revalidatePath("/")
165155
return { success: true }
166156
} catch (error) {
167157
console.error("Error in updateProfile:", error)

lib/auth.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ export async function getUserTeam(session: Session): Promise<UserTeam | undefine
1919
return undefined;
2020
}
2121
console.log("[getUserTeam] Returning static default team for user:", session.user.id);
22-
return createDefaultTeam(session); // Will call the simplified createDefaultTeam
22+
return createDefaultTeam(session);
2323
}
2424

25-
// SIMPLIFIED: Returns a static default team object without database interaction.
2625
async function createDefaultTeam(session: Session): Promise<UserTeam> {
2726
console.log("[createDefaultTeam] Creating static default team object for user:", session.user.id);
2827
const teamName = session.user.user_metadata?.full_name
@@ -98,10 +97,8 @@ export function useAuth(setAuthDialog: (value: boolean) => void, setAuthView: (v
9897
return; // Exit useEffect if supabase is not available
9998
}
10099

101-
// From this point, activeSupabase is defined.
102100
const initializeAuth = async () => {
103101
try {
104-
// The check for activeSupabase being undefined is now handled by the early return above.
105102
const { data: { session: initialSession }, error: initialError } = await activeSupabase.auth.getSession();
106103

107104
if (initialError) {
@@ -136,10 +133,9 @@ export function useAuth(setAuthDialog: (value: boolean) => void, setAuthView: (v
136133
console.error(`[useAuth] Error during team setup (duration: ${teamSetupEndTime - teamSetupStartTime}ms, possibly timeout):`, error.message);
137134
if (error.message === 'Team setup timed out') {
138135
setAuthError("User team setup took too long. Using default settings. Please refresh if issues persist.");
139-
// Ensure a fallback team is set if setupUserTeam hung and didn't set one.
140-
// setupUserTeam is designed to set a fallback in its own catch, but this handles a complete hang.
136+
141137
setUserTeam(currentTeam => {
142-
if (currentTeam) return currentTeam; // Already set by a part of setupUserTeam or its internal fallback
138+
if (currentTeam) return currentTeam;
143139
console.warn("[useAuth] Timeout fallback: Setting a minimal team as setupUserTeam hung.");
144140
return {
145141
id: `timeout_fallback_${initialSession.user.id.replace(/-/g, "").substring(0, 16)}`,
@@ -149,14 +145,11 @@ export function useAuth(setAuthDialog: (value: boolean) => void, setAuthView: (v
149145
};
150146
});
151147
} else {
152-
// For other errors not caught by setupUserTeam's internal try/catch (should be rare)
153148
setAuthError("An unexpected error occurred during team setup.");
154149
}
155150
}
156151

157-
// Proceed with user metadata update and PostHog identification
158152
if (!initialSession.user.user_metadata?.is_fragments_user) {
159-
// Add a small delay to allow session to fully settle after OAuth redirect
160153
await new Promise(resolve => setTimeout(resolve, 500));
161154
try {
162155
await activeSupabase.auth.updateUser({
@@ -185,7 +178,6 @@ export function useAuth(setAuthDialog: (value: boolean) => void, setAuthView: (v
185178

186179
initializeAuth();
187180

188-
// Fallback timeout to ensure isLoading is eventually set to false
189181
const loadingFallbackTimeout = setTimeout(() => {
190182
setIsLoading(currentIsLoading => {
191183
if (currentIsLoading) {
@@ -194,7 +186,7 @@ export function useAuth(setAuthDialog: (value: boolean) => void, setAuthView: (v
194186
}
195187
return false;
196188
});
197-
}, 20000); // Increased to 20 seconds
189+
}, 20000);
198190

199191
const {
200192
data: { subscription },

lib/models.json

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,25 @@
204204
"multiModal": true
205205
},
206206
{
207-
"id": "codestral-2501",
207+
"id": "magistral-medium-latest",
208208
"provider": "Mistral",
209209
"providerId": "mistral",
210-
"name": "Codestral 25.01",
211-
"multiModal": false
210+
"name": "Magistral Medium",
211+
"multiModal": true
212+
},
213+
{
214+
"id": "magistral-small-latest",
215+
"provider": "Mistral",
216+
"providerId": "mistral",
217+
"name": "Magistral Small",
218+
"multiModal": true
219+
},
220+
{
221+
"id": "mistral-medium-latest",
222+
"provider": "Mistral",
223+
"providerId": "mistral",
224+
"name": "Mistral Medium",
225+
"multiModal": true
212226
},
213227
{
214228
"id": "mistral-large-latest",
@@ -238,6 +252,20 @@
238252
"name": "Mistral Nemo",
239253
"multiModal": false
240254
},
255+
{
256+
"id": "devstral-small-latest",
257+
"provider": "Mistral",
258+
"providerId": "mistral",
259+
"name": "Devstral Small",
260+
"multiModal": false
261+
},
262+
{
263+
"id": "codestral-latest",
264+
"provider": "Mistral",
265+
"providerId": "mistral",
266+
"name": "Codestral 25.01",
267+
"multiModal": false
268+
},
241269
{
242270
"id": "llama-3.3-70b-versatile",
243271
"provider": "Groq",
@@ -336,4 +364,4 @@
336364
"multiModal": false
337365
}
338366
]
339-
}
367+
}

lib/prompt.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,6 @@ export function generateProductionPrompt(
594594
return prompt;
595595
}
596596

597-
// Generate context analysis from uploaded files
598597
function generateContextAnalysis(context: ProjectContext): string {
599598
if (!context.files || context.files.length === 0) {
600599
return 'No project files uploaded - working within template constraints only.';
@@ -627,7 +626,6 @@ function generateContextAnalysis(context: ProjectContext): string {
627626
</uploaded_project_analysis>`;
628627
}
629628

630-
// Utility function for file size formatting
631629
function formatFileSize(bytes: number): string {
632630
if (bytes === 0) return '0 B';
633631
const k = 1024;
@@ -636,7 +634,6 @@ function formatFileSize(bytes: number): string {
636634
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
637635
}
638636

639-
// Analyze uploaded files to build project context
640637
function analyzeProjectContext(files: UploadedFile[]): ProjectContext {
641638
const dependencies = new Set<string>();
642639
const frameworks = new Set<string>();
@@ -646,7 +643,6 @@ function analyzeProjectContext(files: UploadedFile[]): ProjectContext {
646643
const existingUtilities = new Set<string>();
647644

648645
files.forEach(file => {
649-
// Extract dependencies from imports
650646
if (file.imports) {
651647
file.imports.forEach(imp => {
652648
if (imp.startsWith('@') || !imp.startsWith('.')) {
@@ -655,7 +651,6 @@ function analyzeProjectContext(files: UploadedFile[]): ProjectContext {
655651
});
656652
}
657653

658-
// Identify frameworks based on content analysis
659654
const content = file.content.toLowerCase();
660655

661656
if (content.includes('import react') || content.includes('from "react"') || content.includes("from 'react'")) {
@@ -680,7 +675,6 @@ function analyzeProjectContext(files: UploadedFile[]): ProjectContext {
680675
frameworks.add('Supabase');
681676
}
682677

683-
// Extract React component names
684678
const componentMatches = file.content.match(/(?:export\s+(?:default\s+)?(?:function|const)\s+([A-Z][a-zA-Z0-9]*)|class\s+([A-Z][a-zA-Z0-9]*)\s+extends)/g);
685679
if (componentMatches) {
686680
componentMatches.forEach(match => {
@@ -691,7 +685,6 @@ function analyzeProjectContext(files: UploadedFile[]): ProjectContext {
691685
});
692686
}
693687

694-
// Extract type and interface definitions
695688
const typeMatches = file.content.match(/(?:type|interface)\s+([A-Z][a-zA-Z0-9]*)/g);
696689
if (typeMatches) {
697690
typeMatches.forEach(match => {
@@ -702,7 +695,6 @@ function analyzeProjectContext(files: UploadedFile[]): ProjectContext {
702695
});
703696
}
704697

705-
// Extract utility functions and constants
706698
const utilityMatches = file.content.match(/(?:export\s+(?:function|const)\s+([a-z][a-zA-Z0-9]*)|function\s+([a-z][a-zA-Z0-9]*)\s*\()/g);
707699
if (utilityMatches) {
708700
utilityMatches.forEach(match => {
@@ -713,7 +705,6 @@ function analyzeProjectContext(files: UploadedFile[]): ProjectContext {
713705
});
714706
}
715707

716-
// Identify coding patterns
717708
if (content.includes('usestate') || content.includes('useeffect') || content.includes('usecallback')) {
718709
patterns.add('React Hooks');
719710
}
@@ -746,7 +737,6 @@ function analyzeProjectContext(files: UploadedFile[]): ProjectContext {
746737
};
747738
}
748739

749-
// Enhanced prompt function with file analysis
750740
export function toEnhancedPrompt(
751741
template: TemplatesDataObject,
752742
userPrompt: string,
@@ -761,7 +751,6 @@ export function toEnhancedPrompt(
761751
);
762752
}
763753

764-
// Legacy compatibility function
765754
export function toPrompt(template: TemplatesDataObject): string {
766755
return generateProductionPrompt(template, "Generate a production-ready application fragment.");
767756
}

lib/tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "CodinIT AI App Builder",
2+
"name": "CodinIT.dev",
33
"description": "Production-grade AI application builder using E2B fragments with multi-framework support",
44
"version": "1.0.0",
55
"capabilities": {

public/placeholder.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)