diff --git a/src/components/chat/chat-input.tsx b/src/components/chat/chat-input.tsx index d4c66e9..9b6edc8 100644 --- a/src/components/chat/chat-input.tsx +++ b/src/components/chat/chat-input.tsx @@ -28,6 +28,7 @@ interface ChatInputProps { availableCommands?: AvailableCommandInfo[] | null attachmentTabId?: string | null draftStorageKey?: string | null + isActive?: boolean } export function ChatInput({ @@ -47,6 +48,7 @@ export function ChatInput({ availableCommands, attachmentTabId, draftStorageKey, + isActive, }: ChatInputProps) { const t = useTranslations("Folder.chat.chatInput") const isConnected = status === "connected" @@ -73,6 +75,7 @@ export function ChatInput({ availableCommands={availableCommands} attachmentTabId={attachmentTabId} draftStorageKey={draftStorageKey} + isActive={isActive} placeholder={ isConnecting ? t("connecting") diff --git a/src/components/chat/conversation-shell.tsx b/src/components/chat/conversation-shell.tsx index 45e4663..ce0761a 100644 --- a/src/components/chat/conversation-shell.tsx +++ b/src/components/chat/conversation-shell.tsx @@ -33,6 +33,7 @@ interface ConversationShellProps { attachmentTabId?: string | null draftStorageKey?: string | null hideInput?: boolean + isActive?: boolean } export function ConversationShell({ @@ -57,6 +58,7 @@ export function ConversationShell({ attachmentTabId, draftStorageKey, hideInput = false, + isActive, }: ConversationShellProps) { return (
@@ -85,6 +87,7 @@ export function ConversationShell({ availableCommands={availableCommands} attachmentTabId={attachmentTabId} draftStorageKey={draftStorageKey} + isActive={isActive} /> )} diff --git a/src/components/chat/message-input.tsx b/src/components/chat/message-input.tsx index 3bfaa05..f704005 100644 --- a/src/components/chat/message-input.tsx +++ b/src/components/chat/message-input.tsx @@ -54,6 +54,7 @@ interface MessageInputProps { promptCapabilities: PromptCapabilitiesInfo attachmentTabId?: string | null draftStorageKey?: string | null + isActive?: boolean } interface ResourceInputAttachment { @@ -252,6 +253,7 @@ export function MessageInput({ promptCapabilities, attachmentTabId, draftStorageKey, + isActive = false, }: MessageInputProps) { const t = useTranslations("Folder.chat.messageInput") const effectiveDraftStorageKey = draftStorageKey ?? attachmentTabId ?? null @@ -263,11 +265,20 @@ export function MessageInput({ const [attachments, setAttachments] = useState([]) const [isDragActive, setIsDragActive] = useState(false) const containerRef = useRef(null) + const textareaRef = useRef(null) const lastDomDropAtRef = useRef(0) const composingRef = useRef(false) const textRef = useRef(text) const disabledRef = useRef(disabled) const isPromptingRef = useRef(isPrompting) + + useEffect(() => { + if (isActive && !disabled && !isPrompting) { + requestAnimationFrame(() => { + textareaRef.current?.focus() + }) + } + }, [isActive, disabled, isPrompting]) const dragActiveRef = useRef(false) const canAttachImages = promptCapabilities.image @@ -1001,6 +1012,7 @@ export function MessageInput({ /> )}