diff --git a/frontend/src/components/message/EditableUserMessage.tsx b/frontend/src/components/message/EditableUserMessage.tsx index d862d7fd..a9a58aa1 100644 --- a/frontend/src/components/message/EditableUserMessage.tsx +++ b/frontend/src/components/message/EditableUserMessage.tsx @@ -1,6 +1,7 @@ import { memo, useState, useRef, useEffect } from 'react' import { Send, X, Pencil, Loader2 } from 'lucide-react' import { useRefreshMessage } from '@/hooks/useRemoveMessage' +import { useUIState } from '@/stores/uiStateStore' interface EditableUserMessageProps { opcodeUrl: string @@ -26,6 +27,7 @@ export const EditableUserMessage = memo(function EditableUserMessage({ const [editedContent, setEditedContent] = useState(content) const textareaRef = useRef(null) const refreshMessage = useRefreshMessage({ opcodeUrl, sessionId, directory }) + const setIsEditingMessage = useUIState((state) => state.setIsEditingMessage) useEffect(() => { if (textareaRef.current) { @@ -76,6 +78,8 @@ export const EditableUserMessage = memo(function EditableUserMessage({ value={editedContent} onChange={(e) => setEditedContent(e.target.value)} onKeyDown={handleKeyDown} + onFocus={() => setIsEditingMessage(true)} + onBlur={() => setIsEditingMessage(false)} className="w-full p-3 rounded-lg bg-background border border-primary/50 focus:border-primary focus:ring-1 focus:ring-primary outline-none resize-none min-h-[60px] text-sm" placeholder="Edit your message..." disabled={refreshMessage.isPending} @@ -136,11 +140,11 @@ export const ClickableUserMessage = memo(function ClickableUserMessage({ return ( ) }) \ No newline at end of file diff --git a/frontend/src/components/message/PromptInput.tsx b/frontend/src/components/message/PromptInput.tsx index 8033ebcd..a3f7932c 100644 --- a/frontend/src/components/message/PromptInput.tsx +++ b/frontend/src/components/message/PromptInput.tsx @@ -74,6 +74,7 @@ export const PromptInput = forwardRef(funct setSelectedAgent(null) if (textareaRef.current) { textareaRef.current.style.height = 'auto' + textareaRef.current.focus() } } }), []) @@ -485,11 +486,7 @@ export const PromptInput = forwardRef(funct - useEffect(() => { - if (textareaRef.current && !disabled) { - textareaRef.current.focus() - } - }, [disabled]) + useEffect(() => { onPromptChange?.(prompt.trim().length > 0) @@ -498,7 +495,7 @@ export const PromptInput = forwardRef(funct return ( -
+