AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(frontend): Refocus ChatInput after voice transcription completes (#11893)
Otto7cb1e588b0d5
diff --git a/autogpt_platform/frontend/src/components/contextual/Chat/components/ChatInput/ChatInput.tsx b/autogpt_platform/frontend/src/components/contextual/Chat/components/ChatInput/ChatInput.tsxindex 521f6f6320..beb4678e73 100644--- a/autogpt_platform/frontend/src/components/contextual/Chat/components/ChatInput/ChatInput.tsx+++ b/autogpt_platform/frontend/src/components/contextual/Chat/components/ChatInput/ChatInput.tsx@@ -57,6 +57,7 @@ export function ChatInput({isStreaming,value,baseHandleKeyDown,+ inputId,});return (diff --git a/autogpt_platform/frontend/src/components/contextual/Chat/components/ChatInput/useVoiceRecording.ts b/autogpt_platform/frontend/src/components/contextual/Chat/components/ChatInput/useVoiceRecording.tsindex 13b625e69c..4de74ef2e9 100644--- a/autogpt_platform/frontend/src/components/contextual/Chat/components/ChatInput/useVoiceRecording.ts+++ b/autogpt_platform/frontend/src/components/contextual/Chat/components/ChatInput/useVoiceRecording.ts@@ -15,6 +15,7 @@ interface Args {isStreaming?: boolean;value: string;baseHandleKeyDown: (event: KeyboardEvent<HTMLTextAreaElement>) => void;+ inputId?: string;}export function useVoiceRecording({@@ -23,6 +24,7 @@ export function useVoiceRecording({isStreaming = false,value,baseHandleKeyDown,+ inputId,}: Args) {const [isRecording, setIsRecording] = useState(false);const [isTranscribing, setIsTranscribing] = useState(false);@@ -103,7 +105,7 @@ export function useVoiceRecording({setIsTranscribing(false);}},- [handleTranscription],+ [handleTranscription, inputId],);const stopRecording = useCallback(() => {@@ -201,6 +203,15 @@ export function useVoiceRecording({}}, [error, toast]);+ useEffect(() => {+ if (!isTranscribing && inputId) {+ const inputElement = document.getElementById(inputId);+ if (inputElement) {+ inputElement.focus();+ }+ }+ }, [isTranscribing, inputId]);+const handleKeyDown = useCallback((event: KeyboardEvent<HTMLTextAreaElement>) => {if (event.key === " " && !value.trim() && !isTranscribing) {