From 16a3267e6960878245ba8ae56e3af98d2d4937f8 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Tue, 10 Mar 2026 23:54:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E4=BC=9A=E8=AF=9D=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E4=BC=9A=E8=AF=9D=E8=BE=93=E5=85=A5=E6=A1=86=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=8E=B7=E5=BE=97=E7=84=A6=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/chat/chat-input.tsx | 3 +++ src/components/chat/conversation-shell.tsx | 3 +++ src/components/chat/message-input.tsx | 12 ++++++++++++ .../conversations/conversation-detail-panel.tsx | 2 ++ 4 files changed, 20 insertions(+) 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({ /> )}