diff --git a/src/ui/components/chat/message-input.tsx b/src/ui/components/chat/message-input.tsx index 27492e12..014b64cc 100644 --- a/src/ui/components/chat/message-input.tsx +++ b/src/ui/components/chat/message-input.tsx @@ -140,6 +140,20 @@ export const ChatInput = React.forwardRef( } }, [initialText]) + // Focus editor when replyingTo becomes truthy + useEffect(() => { + if (replyingTo && editorRef.current) { + editorRef.current.focus() + // Focus and move cursor to end + const range = document.createRange() + const sel = window.getSelection() + range.selectNodeContents(editorRef.current) + range.collapse(false) + sel?.removeAllRanges() + sel?.addRange(range) + } + }, [replyingTo]) + // Clean up drawing mode on unmount useEffect(() => { return () => {