@@ -24,6 +24,7 @@ import {
2424 AttachedFilesList ,
2525 DropOverlay ,
2626 MicButton ,
27+ MicrophonePermissionHelp ,
2728 PromptEditor ,
2829 SendButton ,
2930 usePromptEditor ,
@@ -102,6 +103,7 @@ const UserInputImpl = forwardRef<UserInputHandle, UserInputProps>(function UserI
102103 const { workspaceId } = useParams < { workspaceId : string } > ( )
103104 const { navigateToSettings } = useSettingsNavigation ( )
104105 const { userId, onContextAdd, onContextRemove } = useChatSurface ( )
106+ const [ microphonePermissionHelpOpen , setMicrophonePermissionHelpOpen ] = useState ( false )
105107
106108 const [ initialValue ] = useState ( ( ) => {
107109 if ( defaultValue ) return defaultValue
@@ -323,19 +325,27 @@ const UserInputImpl = forwardRef<UserInputHandle, UserInputProps>(function UserI
323325 function handleSpeechError ( error : SpeechToTextError ) {
324326 if ( error === 'microphone-blocked' ) {
325327 const desktopBridge = getDesktopBridge ( )
326- toast . error (
327- desktopBridge
328- ? 'Microphone access is blocked. Allow Sim to use the microphone in your system privacy settings.'
329- : 'Microphone access is blocked. Allow it for this site and try again.' ,
330- desktopBridge ?. openMicrophoneSettings
331- ? {
332- action : {
333- label : 'Open Settings' ,
334- onClick : ( ) => void desktopBridge . openMicrophoneSettings ?.( ) ,
335- } ,
336- }
337- : undefined
338- )
328+ if ( desktopBridge ) {
329+ const { openMicrophoneSettings } = desktopBridge
330+ toast . error (
331+ 'Microphone access is blocked. Allow Sim to use the microphone in your system privacy settings.' ,
332+ openMicrophoneSettings
333+ ? {
334+ action : {
335+ label : 'Open Settings' ,
336+ onClick : ( ) => void openMicrophoneSettings ( ) ,
337+ } ,
338+ }
339+ : undefined
340+ )
341+ } else {
342+ toast . error ( 'Microphone access is blocked. Allow it for this site and try again.' , {
343+ action : {
344+ label : 'Show steps' ,
345+ onClick : ( ) => setMicrophonePermissionHelpOpen ( true ) ,
346+ } ,
347+ } )
348+ }
339349 return
340350 }
341351 if ( error === 'microphone-unavailable' ) {
@@ -504,7 +514,7 @@ const UserInputImpl = forwardRef<UserInputHandle, UserInputProps>(function UserI
504514
505515 const handleContainerClick = useCallback (
506516 ( e : React . MouseEvent < HTMLDivElement > ) => {
507- if ( ( e . target as HTMLElement ) . closest ( 'button' ) ) return
517+ if ( ( e . target as HTMLElement ) . closest ( 'button, [role="dialog"] ' ) ) return
508518 textareaRef . current ?. focus ( )
509519 } ,
510520 [ textareaRef ]
@@ -697,6 +707,11 @@ const UserInputImpl = forwardRef<UserInputHandle, UserInputProps>(function UserI
697707 />
698708
699709 { files . isDragging && < DropOverlay /> }
710+
711+ < MicrophonePermissionHelp
712+ open = { microphonePermissionHelpOpen }
713+ onOpenChange = { setMicrophonePermissionHelpOpen }
714+ />
700715 </ div >
701716 )
702717} )
0 commit comments