1- // File: app/page.tsx
21"use client"
32
43import type React from "react"
@@ -34,7 +33,32 @@ const TEMPLATE_IDS = {
3433 CODINIT_ENGINEER : "codinit-engineer" ,
3534} as const ;
3635
37- // Error types and handling
36+ interface ProjectAnalysis {
37+ structure : {
38+ files : Array < {
39+ name : string
40+ path : string
41+ language : string
42+ size : number
43+ type : string
44+ content ?: string // Added content for easier File creation
45+ } >
46+ dependencies : Set < string >
47+ frameworks : Set < string >
48+ patterns : Set < string >
49+ components : Set < string >
50+ types : Set < string >
51+ utilities : Set < string >
52+ architecture : {
53+ type : string
54+ description : string
55+ }
56+ configFiles ?: string [ ] // Added configFiles based on EnhancedChatInput logic
57+ }
58+ analysis : string
59+ recommendations : string [ ]
60+ }
61+
3862type ParsedApiError = { code : string ; message : string ; rawData : any } ;
3963
4064const parseApiError = ( error : Error | any ) : ParsedApiError => {
@@ -175,30 +199,6 @@ async function handleSandboxCreation(
175199 return responseData as ExecutionResult ;
176200}
177201
178- interface ProjectAnalysis {
179- structure : {
180- files : Array < {
181- name : string
182- path : string
183- language : string
184- size : number
185- type : string
186- } >
187- dependencies : Set < string >
188- frameworks : Set < string >
189- patterns : Set < string >
190- components : Set < string >
191- types : Set < string >
192- utilities : Set < string >
193- architecture : {
194- type : string
195- description : string
196- }
197- }
198- analysis : string
199- recommendations : string [ ]
200- }
201-
202202export default function Home ( ) {
203203 const [ chatInput , setChatInput ] = useLocalStorage ( "chat" , "" )
204204 const [ files , setFiles ] = useState < File [ ] > ( [ ] )
@@ -518,6 +518,7 @@ export default function Home() {
518518 template : selectedTemplate ,
519519 hasProjectFiles : ! ! ( projectFiles && projectFiles . length > 0 ) ,
520520 hasProjectAnalysis : ! ! projectAnalysis ,
521+ isGitHubImport : ! ! ( projectAnalysis && projectAnalysis . structure ) ,
521522 } )
522523
523524 try {
@@ -541,6 +542,10 @@ export default function Home() {
541542 model : languageModel . model ,
542543 requestId,
543544 hasProjectContext : ! ! ( projectFiles && projectFiles . length > 0 ) ,
545+ importSource : projectAnalysis ? "github" : projectFiles ? "upload" : "none" ,
546+ gitHubRepository : projectAnalysis ?. structure ?. configFiles ?. some ( f =>
547+ f . includes ( 'package.json' ) || f . includes ( '.git' )
548+ ) ? "detected" : "none" ,
544549 } )
545550 } catch ( error : any ) {
546551 console . error ( "[handleSubmitAuth] Submit error:" , error )
@@ -584,6 +589,7 @@ export default function Home() {
584589 messagesCount : submitData . messages . length ,
585590 model : submitData . model . id ,
586591 hasProjectContext : ! ! ( projectContext . files . length > 0 ) ,
592+ hasGitHubAnalysis : ! ! projectContext . analysis ,
587593 } )
588594
589595 submit ( submitData )
0 commit comments