22"use client"
33
44import React from "react"
5- import { useRouter } from "next/navigation"
65
76import type { ViewType } from "@/components/auth"
87import { AuthDialog } from "@/components/auth-dialog"
@@ -24,18 +23,8 @@ import type { ExecutionResult } from "@/lib/types"
2423import type { DeepPartial } from "ai"
2524import { experimental_useObject as useObject } from "ai/react"
2625import { usePostHog } from "posthog-js/react"
27- import { type SetStateAction , useCallback , useEffect , useState } from "react"
26+ import { useCallback , useEffect , useState } from "react"
2827import { useLocalStorage } from "usehooks-ts"
29- import posthog from "posthog-js"
30-
31- const TEMPLATE_IDS = {
32- CODE_INTERPRETER_V1 : "code-interpreter-v1" ,
33- NEXTJS_DEVELOPER : "nextjs-developer" ,
34- VUE_DEVELOPER : "vue-developer" ,
35- STREAMLIT_DEVELOPER : "streamlit-developer" ,
36- GRADIO_DEVELOPER : "gradio-developer" ,
37- CODINIT_ENGINEER : "codinit-engineer" ,
38- } as const
3928
4029interface ProjectAnalysis {
4130 structure : {
@@ -99,14 +88,13 @@ const parseApiError = (error: Error | any): ParsedApiError => {
9988}
10089
10190export default function Home ( ) {
102- const router = useRouter ( )
10391 const posthog = usePostHog ( )
10492
10593 // Auth and session state
10694 const [ isAuthDialogOpen , setAuthDialog ] = useState ( false )
10795 const [ authView , setAuthView ] = useState < ViewType > ( "sign_in" )
10896 const [ authError , setAuthError ] = useState < string | null > ( null )
109- const { session, isLoading, userTeam, authError : authStateError } = useAuth ( setAuthDialog , setAuthView )
97+ const { session, isLoading, userTeam } = useAuth ( setAuthDialog , setAuthView )
11098
11199 // Chat and UI state
112100 const [ messages , setMessages ] = useState < Message [ ] > ( [ ] )
@@ -123,6 +111,7 @@ export default function Home() {
123111 const [ errorMessage , setErrorMessage ] = useState ( "" )
124112 const [ isRateLimited , setIsRateLimited ] = useState ( false )
125113 const [ currentRequestId , setCurrentRequestId ] = useState < string > ( "" )
114+ const [ hasMounted , setHasMounted ] = useState ( false )
126115 const [ projectContext , setProjectContext ] = useState < {
127116 files : File [ ]
128117 analysis : ProjectAnalysis | null
@@ -161,6 +150,7 @@ export default function Home() {
161150 // Fragment state management
162151 const [ fragment , setFragment ] = useState < FragmentSchema | null > ( null )
163152 const [ result , setResult ] = useState < ExecutionResult | undefined > ( )
153+ const [ isSettingsDialogOpen , setIsSettingsDialogOpen ] = useState ( false )
164154
165155 // Navigation and action handlers
166156 const handleSocialClick = useCallback ( ( platform : string ) => {
@@ -340,6 +330,11 @@ export default function Home() {
340330 }
341331 } , [ error , stop ] )
342332
333+ // Effect to track component mounting for client-side only logic
334+ useEffect ( ( ) => {
335+ setHasMounted ( true )
336+ } , [ ] )
337+
343338 // Main form submission handler
344339 const handleSubmitAuth = useCallback ( async (
345340 e : React . FormEvent < HTMLFormElement > ,
@@ -556,6 +551,7 @@ export default function Home() {
556551 models = { availableModels }
557552 languageModel = { languageModel }
558553 onLanguageModelChange = { handleLanguageModelChange }
554+ hasMounted = { hasMounted }
559555 />
560556 < ChatSettings
561557 apiKeyConfigurable = { ! process . env . NEXT_PUBLIC_NO_API_KEY_INPUT }
@@ -589,7 +585,7 @@ export default function Home() {
589585 { /* Command Palette Integration */ }
590586 < CommandPalette
591587 onCreateFragment = { ( ) => {
592- setChatInput ( "Create a new React component with modern best practices including TypeScript, responsive design, and accessibility features." )
588+ setChatInput ( "Create a new Next.js React component with modern best practices including TypeScript, responsive design, and accessibility features." )
593589 setSelectedTemplate ( "nextjs-developer" )
594590
595591 setTimeout ( ( ) => {
@@ -601,9 +597,8 @@ export default function Home() {
601597 } }
602598 onClearChat = { handleClearChat }
603599 onOpenSettings = { ( ) => {
604- router . push ( '/settings' )
605600 } }
606601 />
607602 </ div >
608603 )
609- }
604+ }
0 commit comments