@@ -3,6 +3,7 @@ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
33import * as DialogPrimitive from "@radix-ui/react-dialog" ;
44import { ArrowUp , Paperclip , Square , X , StopCircle , Mic , Globe , BrainCog , FolderCog } from "lucide-react" ;
55import { motion , AnimatePresence } from "framer-motion" ;
6+ import Image from "next/image" ;
67import { ChatSettings } from '../chat-settings'
78import { ChatPicker } from '../chat-picker'
89import { LLMModel , LLMModelConfig } from '@/lib/models'
@@ -182,13 +183,17 @@ const VoiceRecorder: React.FC<VoiceRecorderProps> = ({
182183 clearInterval ( timerRef . current ) ;
183184 timerRef . current = null ;
184185 }
185- onStopRecording ( time ) ;
186- setTime ( 0 ) ;
186+ setTime ( currentTime => {
187+ if ( currentTime > 0 ) {
188+ onStopRecording ( currentTime ) ;
189+ }
190+ return 0 ;
191+ } ) ;
187192 }
188193 return ( ) => {
189194 if ( timerRef . current ) clearInterval ( timerRef . current ) ;
190195 } ;
191- } , [ isRecording , time , onStartRecording , onStopRecording ] ) ;
196+ } , [ isRecording , onStartRecording , onStopRecording ] ) ;
192197
193198 const formatTime = ( seconds : number ) => {
194199 const mins = Math . floor ( seconds / 60 ) ;
@@ -242,10 +247,12 @@ const ImageViewDialog: React.FC<ImageViewDialogProps> = ({ imageUrl, onClose })
242247 transition = { { duration : 0.2 , ease : "easeOut" } }
243248 className = "relative bg-background rounded-2xl overflow-hidden shadow-2xl"
244249 >
245- < img
250+ < Image
246251 src = { imageUrl }
247252 alt = "Full preview"
248- className = "w-full max-h-[80vh] object-contain rounded-2xl"
253+ fill
254+ className = "object-contain rounded-2xl"
255+ sizes = "(max-width: 768px) 95vw, (max-width: 1200px) 80vw, 70vw"
249256 />
250257 </ motion . div >
251258 </ DialogContent >
@@ -479,11 +486,11 @@ export const PromptInputBox = React.forwardRef((props: PromptInputBoxProps, ref:
479486 }
480487 } ;
481488
482- const handleCanvasToggle = ( ) => setShowCanvas ( ( prev ) => ! prev ) ;
489+ const handleCanvasToggle = ( ) => setShowCanvas ( prev => ! prev ) ;
483490
484491 const isImageFile = ( file : File ) => file . type . startsWith ( "image/" ) ;
485492
486- const processFile = ( file : File ) => {
493+ const processFile = React . useCallback ( ( file : File ) => {
487494 if ( ! isImageFile ( file ) ) {
488495 console . log ( "Only image files are allowed" ) ;
489496 return ;
@@ -496,7 +503,7 @@ export const PromptInputBox = React.forwardRef((props: PromptInputBoxProps, ref:
496503 const reader = new FileReader ( ) ;
497504 reader . onload = ( e ) => setFilePreviews ( { [ file . name ] : e . target ?. result as string } ) ;
498505 reader . readAsDataURL ( file ) ;
499- } ;
506+ } , [ ] ) ;
500507
501508 const handleDragOver = React . useCallback ( ( e : React . DragEvent ) => {
502509 e . preventDefault ( ) ;
@@ -514,7 +521,7 @@ export const PromptInputBox = React.forwardRef((props: PromptInputBoxProps, ref:
514521 const files = Array . from ( e . dataTransfer . files ) ;
515522 const imageFiles = files . filter ( ( file ) => isImageFile ( file ) ) ;
516523 if ( imageFiles . length > 0 ) processFile ( imageFiles [ 0 ] ) ;
517- } , [ ] ) ;
524+ } , [ processFile ] ) ;
518525
519526 const handleRemoveFile = ( index : number ) => {
520527 const fileToRemove = files [ index ] ;
@@ -537,7 +544,7 @@ export const PromptInputBox = React.forwardRef((props: PromptInputBoxProps, ref:
537544 }
538545 }
539546 }
540- } , [ ] ) ;
547+ } , [ processFile ] ) ;
541548
542549 React . useEffect ( ( ) => {
543550 document . addEventListener ( "paste" , handlePaste ) ;
@@ -608,13 +615,15 @@ export const PromptInputBox = React.forwardRef((props: PromptInputBoxProps, ref:
608615 < div key = { index } className = "relative group" >
609616 { file . type . startsWith ( "image/" ) && filePreviews [ file . name ] && (
610617 < div
611- className = "w-16 h-16 rounded-xl overflow-hidden cursor-pointer transition-all duration-300"
618+ className = "relative w-16 h-16 rounded-xl overflow-hidden cursor-pointer transition-all duration-300"
612619 onClick = { ( ) => openImageModal ( filePreviews [ file . name ] ) }
613620 >
614- < img
621+ < Image
615622 src = { filePreviews [ file . name ] }
616623 alt = { file . name }
617- className = "h-full w-full object-cover"
624+ fill
625+ className = "object-cover"
626+ sizes = "64px"
618627 />
619628 < button
620629 onClick = { ( e ) => {
0 commit comments