@@ -159,14 +159,14 @@ function ConfigForm({ config, onSubmit }: ConfigFormProps) {
159
159
const videoDevices = [
160
160
{ deviceId : "none" , label : "No Video" } ,
161
161
...devices
162
- . filter ( ( device ) => device . kind === "videoinput" )
162
+ . filter ( ( device ) => device . kind === "videoinput" && device . deviceId )
163
163
. map ( ( device ) => ( {
164
164
deviceId : device . deviceId ,
165
165
label : device . label || `Camera ${ device . deviceId . slice ( 0 , 5 ) } ...` ,
166
166
} ) )
167
167
] ;
168
-
169
168
setVideoDevices ( videoDevices ) ;
169
+
170
170
// Set default to first available camera if no selection yet
171
171
if ( ! selectedDevice && videoDevices . length > 1 ) {
172
172
setSelectedDevice ( videoDevices [ 1 ] . deviceId ) ; // Index 1 because 0 is "No Video"
@@ -178,29 +178,34 @@ function ConfigForm({ config, onSubmit }: ConfigFormProps) {
178
178
} ) ;
179
179
180
180
// If we can't access video devices, still provide the None option
181
- const videoDevices = [ { deviceId : "none" , label : "No Video" } ] ;
182
- setVideoDevices ( videoDevices ) ;
181
+ setVideoDevices ( [ { deviceId : "none" , label : "No Video" } ] ) ;
183
182
setSelectedDevice ( "none" ) ;
184
183
}
185
184
} , [ selectedDevice ] ) ;
186
185
186
+ /**
187
+ * Retrieves the list of audio devices available on the user's device.
188
+ */
187
189
const getAudioDevices = useCallback ( async ( ) => {
188
190
try {
189
191
const devices = await navigator . mediaDevices . enumerateDevices ( ) ;
190
192
const audioDevices = [
191
193
{ deviceId : "none" , label : "No Audio" } ,
192
194
...devices
193
- . filter ( ( device ) => device . kind === "audioinput" )
195
+ . filter ( ( device ) => device . kind === "audioinput" && device . deviceId )
194
196
. map ( ( device ) => ( {
195
197
deviceId : device . deviceId ,
196
198
label : device . label || `Microphone ${ device . deviceId . slice ( 0 , 5 ) } ...` ,
197
199
} ) )
198
200
] ;
199
-
200
201
setAudioDevices ( audioDevices ) ;
202
+
201
203
// Set default to first available microphone if no selection yet
202
204
if ( ! selectedAudioDevice && audioDevices . length > 1 ) {
203
205
setSelectedAudioDevice ( audioDevices [ 0 ] . deviceId ) ; // Default to "No Audio" for now
206
+ } else {
207
+ setAudioDevices ( [ { deviceId : "none" , label : "No Audio" } ] ) ;
208
+ setSelectedAudioDevice ( "none" ) ;
204
209
}
205
210
} catch ( error ) {
206
211
console . error ( "Failed to get audio devices: " , error ) ;
@@ -209,8 +214,7 @@ function ConfigForm({ config, onSubmit }: ConfigFormProps) {
209
214
} ) ;
210
215
211
216
// If we can't access audio devices, still provide the None option
212
- const audioDevices = [ { deviceId : "none" , label : "No Audio" } ] ;
213
- setAudioDevices ( audioDevices ) ;
217
+ setAudioDevices ( [ { deviceId : "none" , label : "No Audio" } ] ) ;
214
218
setSelectedAudioDevice ( "none" ) ;
215
219
}
216
220
} , [ selectedAudioDevice ] ) ;
@@ -358,6 +362,7 @@ function ConfigForm({ config, onSubmit }: ConfigFormProps) {
358
362
accept = ".json"
359
363
multiple
360
364
onChange = { handlePromptsChange }
365
+ required = { true }
361
366
/>
362
367
</ div >
363
368
0 commit comments