9
9
SelectTrigger ,
10
10
SelectValue ,
11
11
} from "@/components/ui/select" ;
12
+ import { VoiceInput } from "@/components/VoiceInput" ;
12
13
13
14
// Updated InputFormProps
14
15
interface InputFormProps {
@@ -26,7 +27,7 @@ export const InputForm: React.FC<InputFormProps> = ({
26
27
} ) => {
27
28
const [ internalInputValue , setInternalInputValue ] = useState ( "" ) ;
28
29
const [ effort , setEffort ] = useState ( "medium" ) ;
29
- const [ model , setModel ] = useState ( "gemini-2.5-flash-preview-04-17 " ) ;
30
+ const [ model , setModel ] = useState ( "gemini-2.5-flash" ) ;
30
31
31
32
const handleInternalSubmit = ( e ?: React . FormEvent ) => {
32
33
if ( e ) e . preventDefault ( ) ;
@@ -36,13 +37,35 @@ export const InputForm: React.FC<InputFormProps> = ({
36
37
} ;
37
38
38
39
const handleKeyDown = ( e : React . KeyboardEvent < HTMLTextAreaElement > ) => {
39
- // Submit with Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac)
40
+ // Submit with Enter (not Ctrl+Enter) - this is more intuitive
41
+ if ( e . key === "Enter" && ! e . shiftKey && ! e . ctrlKey && ! e . metaKey ) {
42
+ e . preventDefault ( ) ;
43
+ handleInternalSubmit ( ) ;
44
+ }
45
+ // Allow Shift+Enter for new lines
46
+ // Allow Ctrl+Enter and Cmd+Enter as alternative submit methods
40
47
if ( e . key === "Enter" && ( e . ctrlKey || e . metaKey ) ) {
41
48
e . preventDefault ( ) ;
42
49
handleInternalSubmit ( ) ;
43
50
}
44
51
} ;
45
52
53
+ const handleVoiceTranscription = ( transcription : string , shouldAutoSubmit = false ) => {
54
+ // Append transcription to existing input value or replace if empty
55
+ const newValue = internalInputValue . trim ( )
56
+ ? `${ internalInputValue } ${ transcription } `
57
+ : transcription ;
58
+ console . log ( 'Setting transcription value:' , newValue ) ; // Debug log
59
+ setInternalInputValue ( newValue ) ;
60
+
61
+ // If auto-submit is requested, submit immediately with the new value
62
+ if ( shouldAutoSubmit && newValue . trim ( ) ) {
63
+ console . log ( 'Auto-submitting with new value:' , newValue ) ; // Debug log
64
+ onSubmit ( newValue , effort , model ) ;
65
+ setInternalInputValue ( "" ) ;
66
+ }
67
+ } ;
68
+
46
69
const isSubmitDisabled = ! internalInputValue . trim ( ) || isLoading ;
47
70
48
71
return (
@@ -64,7 +87,16 @@ export const InputForm: React.FC<InputFormProps> = ({
64
87
md:text-base min-h-[56px] max-h-[200px]` }
65
88
rows = { 1 }
66
89
/>
67
- < div className = "-mt-3" >
90
+ < div className = "flex items-center gap-2 -mt-3" >
91
+ { /* Voice Input Button */ }
92
+ < VoiceInput
93
+ onTranscription = { handleVoiceTranscription }
94
+ disabled = { isLoading }
95
+ autoSubmit = { true }
96
+ timeoutDuration = { 15000 } // 15 seconds instead of 30
97
+ />
98
+
99
+ { /* Submit/Cancel Button */ }
68
100
{ isLoading ? (
69
101
< Button
70
102
type = "button"
@@ -144,7 +176,7 @@ export const InputForm: React.FC<InputFormProps> = ({
144
176
</ div >
145
177
</ SelectItem >
146
178
< SelectItem
147
- value = "gemini-2.5-flash-preview-04-17 "
179
+ value = "gemini-2.5-flash"
148
180
className = "hover:bg-neutral-600 focus:bg-neutral-600 cursor-pointer"
149
181
>
150
182
< div className = "flex items-center" >
@@ -176,4 +208,4 @@ export const InputForm: React.FC<InputFormProps> = ({
176
208
</ div >
177
209
</ form >
178
210
) ;
179
- } ;
211
+ } ;
0 commit comments