@@ -158,50 +158,54 @@ function ConfigForm({ config, onSubmit }: ConfigFormProps) {
158
158
const videoDevices = [
159
159
{ deviceId : "none" , label : "No Video" } ,
160
160
...devices
161
- . filter ( ( device ) => device . kind === "videoinput" )
161
+ . filter ( ( device ) => device . kind === "videoinput" && device . deviceId )
162
162
. map ( ( device ) => ( {
163
163
deviceId : device . deviceId ,
164
164
label : device . label || `Camera ${ device . deviceId . slice ( 0 , 5 ) } ...` ,
165
165
} ) )
166
166
] ;
167
-
168
167
setVideoDevices ( videoDevices ) ;
168
+
169
169
// Set default to first available camera if no selection yet
170
170
if ( ! selectedDevice && videoDevices . length > 1 ) {
171
171
setSelectedDevice ( videoDevices [ 1 ] . deviceId ) ; // Index 1 because 0 is "No Video"
172
172
}
173
173
} catch ( err ) {
174
174
console . error ( "Failed to get video devices" ) ;
175
175
// If we can't access video devices, still provide the None option
176
- const videoDevices = [ { deviceId : "none" , label : "No Video" } ] ;
177
- setVideoDevices ( videoDevices ) ;
176
+ setVideoDevices ( [ { deviceId : "none" , label : "No Video" } ] ) ;
178
177
setSelectedDevice ( "none" ) ;
179
178
}
180
179
} , [ selectedDevice ] ) ;
181
180
181
+ /**
182
+ * Retrieves the list of audio devices available on the user's device.
183
+ */
182
184
const getAudioDevices = useCallback ( async ( ) => {
183
185
try {
184
186
const devices = await navigator . mediaDevices . enumerateDevices ( ) ;
185
187
const audioDevices = [
186
188
{ deviceId : "none" , label : "No Audio" } ,
187
189
...devices
188
- . filter ( ( device ) => device . kind === "audioinput" )
190
+ . filter ( ( device ) => device . kind === "audioinput" && device . deviceId )
189
191
. map ( ( device ) => ( {
190
192
deviceId : device . deviceId ,
191
193
label : device . label || `Microphone ${ device . deviceId . slice ( 0 , 5 ) } ...` ,
192
194
} ) )
193
195
] ;
194
-
195
196
setAudioDevices ( audioDevices ) ;
197
+
196
198
// Set default to first available microphone if no selection yet
197
199
if ( ! selectedAudioDevice && audioDevices . length > 1 ) {
198
200
setSelectedAudioDevice ( audioDevices [ 0 ] . deviceId ) ; // Default to "No Audio" for now
201
+ } else {
202
+ setAudioDevices ( [ { deviceId : "none" , label : "No Audio" } ] ) ;
203
+ setSelectedAudioDevice ( "none" ) ;
199
204
}
200
205
} catch ( err ) {
201
206
console . error ( "Failed to get audio devices" ) ;
202
207
// If we can't access audio devices, still provide the None option
203
- const audioDevices = [ { deviceId : "none" , label : "No Audio" } ] ;
204
- setAudioDevices ( audioDevices ) ;
208
+ setAudioDevices ( [ { deviceId : "none" , label : "No Audio" } ] ) ;
205
209
setSelectedAudioDevice ( "none" ) ;
206
210
}
207
211
} , [ selectedAudioDevice ] ) ;
@@ -346,6 +350,7 @@ function ConfigForm({ config, onSubmit }: ConfigFormProps) {
346
350
accept = ".json"
347
351
multiple
348
352
onChange = { handlePromptsChange }
353
+ required = { true }
349
354
/>
350
355
</ div >
351
356
0 commit comments