33import { ViewType } from '@/components/auth' ;
44import { AuthDialog } from '@/components/auth-dialog' ;
55import { Chat } from '@/components/chat' ;
6- import { ChatInput } from '@/components/chat-input ' ;
6+ import { PromptInputBox } from '@/components/ui/ai-prompt-box ' ;
77import { ChatPicker } from '@/components/chat-picker' ;
88import { ChatSettings } from '@/components/chat-settings' ;
99import { NavBar } from '@/components/navbar' ;
@@ -31,8 +31,6 @@ import { SupabaseClient } from '@supabase/supabase-js';
3131
3232export default function Home ( ) {
3333 const supabase = createSupabaseBrowserClient ( )
34- const [ chatInput , setChatInput ] = useLocalStorage ( 'chat' , '' )
35- const [ files , setFiles ] = useState < File [ ] > ( [ ] )
3634 const [ selectedTemplate , setSelectedTemplate ] = useState < 'auto' | TemplateId > ( 'auto' )
3735 const [ languageModel , setLanguageModel ] = useLocalStorage < LLMModelConfig > (
3836 'languageModel' ,
@@ -269,9 +267,7 @@ export default function Home() {
269267 } )
270268 }
271269
272- async function handleSubmitAuth ( e : React . FormEvent < HTMLFormElement > ) {
273- e . preventDefault ( )
274-
270+ async function handleSendPrompt ( message : string , files : File [ ] = [ ] ) {
275271 if ( ! session ) {
276272 return setAuthDialog ( true )
277273 }
@@ -280,10 +276,8 @@ export default function Home() {
280276 stop ( )
281277 }
282278
283- const currentInput = chatInput
284- const currentFiles = [ ...files ]
285- setChatInput ( '' )
286- setFiles ( [ ] )
279+ const currentInput = message
280+ const currentFiles = files
287281 setCurrentTab ( 'code' )
288282
289283 const content : Message [ 'content' ] = [ { type : 'text' , text : currentInput } ]
@@ -368,16 +362,6 @@ export default function Home() {
368362 } )
369363 }
370364
371- const handleSaveInputChange = useCallback (
372- ( e : React . ChangeEvent < HTMLTextAreaElement > ) => {
373- setChatInput ( e . target . value )
374- } ,
375- [ setChatInput ] ,
376- )
377-
378- const handleFileChange = useCallback ( ( change : SetStateAction < File [ ] > ) => {
379- setFiles ( change )
380- } , [ ] )
381365
382366 function logout ( ) {
383367 if ( supabase ) {
@@ -406,8 +390,6 @@ export default function Home() {
406390 window . open ( 'https://github.com/Gerome-Elassaad/CodingIT' , '_blank' )
407391 } else if ( target === 'x' ) {
408392 window . open ( 'https://x.com/codinit_dev' , '_blank' )
409- } else if ( target === 'discord' ) {
410- window . open ( 'https://discord.gg/' , '_blank' )
411393 }
412394
413395 // Enhanced social tracking
@@ -418,8 +400,6 @@ export default function Home() {
418400
419401 function handleClearChat ( ) {
420402 stop ( )
421- setChatInput ( '' )
422- setFiles ( [ ] )
423403 setMessages ( [ ] )
424404 setFragment ( undefined )
425405 setResult ( undefined )
@@ -464,7 +444,7 @@ export default function Home() {
464444 session ? "ml-16" : ""
465445 ) } >
466446 < div
467- className = { `flex flex-col w-full max-h-full max-w-[800px] mx-auto px-4 overflow-auto ${ fragment ? 'col-span-1' : 'col-span-2' } ` }
447+ className = { `flex flex-col w-full h-screen max-w-[800px] mx-auto px-4 ${ fragment ? 'col-span-1' : 'col-span-2' } ` }
468448 >
469449 < NavBar
470450 session = { session }
@@ -481,47 +461,45 @@ export default function Home() {
481461 < HeroPillSecond />
482462 </ div >
483463
484- { isLoadingProject ? (
485- < div className = "flex items-center justify-center h-32" >
486- < div className = "text-muted-foreground" > Loading project...</ div >
487- </ div >
488- ) : (
489- < Chat
490- messages = { messages }
491- isLoading = { isLoading }
492- setCurrentPreview = { setCurrentPreview }
493- />
494- ) }
464+ < div className = "flex-grow overflow-y-auto" >
465+ { isLoadingProject ? (
466+ < div className = "flex items-center justify-center h-32" >
467+ < div className = "text-muted-foreground" > Loading project...</ div >
468+ </ div >
469+ ) : (
470+ < Chat
471+ messages = { messages }
472+ isLoading = { isLoading }
473+ setCurrentPreview = { setCurrentPreview }
474+ />
475+ ) }
476+ </ div >
495477
496- < ChatInput
497- retry = { retry }
498- isErrored = { error !== undefined }
499- errorMessage = { errorMessage }
500- isLoading = { isLoading }
501- isRateLimited = { isRateLimited }
502- stop = { stop }
503- input = { chatInput }
504- handleInputChange = { handleSaveInputChange }
505- handleSubmit = { handleSubmitAuth }
506- isMultiModal = { currentModel ?. multiModal || false }
507- files = { files }
508- handleFileChange = { handleFileChange }
509- >
510- < ChatPicker
511- templates = { templates }
512- selectedTemplate = { selectedTemplate }
513- onSelectedTemplateChange = { setSelectedTemplate }
514- models = { filteredModels }
515- languageModel = { languageModel }
516- onLanguageModelChange = { handleLanguageModelChange }
517- />
518- < ChatSettings
519- languageModel = { languageModel }
520- onLanguageModelChange = { handleLanguageModelChange }
521- apiKeyConfigurable = { ! process . env . NEXT_PUBLIC_NO_API_KEY_INPUT }
522- baseURLConfigurable = { ! process . env . NEXT_PUBLIC_NO_BASE_URL_INPUT }
523- />
524- </ ChatInput >
478+ < div className = "space-y-4 mt-4" >
479+ { error && (
480+ < div className = "flex items-center justify-between p-2 bg-red-500/10 border border-red-500/20 rounded-lg text-red-500 text-sm" >
481+ < span > { errorMessage } </ span >
482+ < button onClick = { retry } className = "ml-4 p-1 rounded-md hover:bg-red-500/20" > Retry</ button >
483+ </ div >
484+ ) }
485+ { isLoading && (
486+ < div className = "flex items-center justify-between p-2" >
487+ < span className = "text-muted-foreground" > Generating response...</ span >
488+ < button onClick = { stop } className = "ml-4 p-1 rounded-md border" > Stop</ button >
489+ </ div >
490+ ) }
491+ < PromptInputBox
492+ onSend = { handleSendPrompt }
493+ templates = { templates }
494+ selectedTemplate = { selectedTemplate }
495+ onSelectedTemplateChange = { setSelectedTemplate }
496+ models = { filteredModels }
497+ languageModel = { languageModel }
498+ onLanguageModelChange = { handleLanguageModelChange }
499+ apiKeyConfigurable = { ! process . env . NEXT_PUBLIC_NO_API_KEY_INPUT }
500+ baseURLConfigurable = { ! process . env . NEXT_PUBLIC_NO_BASE_URL_INPUT }
501+ />
502+ </ div >
525503 </ div >
526504 < Preview
527505 teamID = { userTeam ?. id }
@@ -538,7 +516,8 @@ export default function Home() {
538516 throw new Error ( 'Function not implemented.' ) ;
539517 } } executeCode = { function ( ) : Promise < void > {
540518 throw new Error ( 'Function not implemented.' ) ;
541- } } />
519+ } }
520+ />
542521 </ div >
543522 </ main >
544523 )
0 commit comments