切换会话时,会话输入框自动获得焦点
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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 (
|
||||
<div className="flex h-full min-h-0 flex-col">
|
||||
@@ -85,6 +87,7 @@ export function ConversationShell({
|
||||
availableCommands={availableCommands}
|
||||
attachmentTabId={attachmentTabId}
|
||||
draftStorageKey={draftStorageKey}
|
||||
isActive={isActive}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
@@ -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<InputAttachment[]>([])
|
||||
const [isDragActive, setIsDragActive] = useState(false)
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(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({
|
||||
/>
|
||||
)}
|
||||
<Textarea
|
||||
ref={textareaRef}
|
||||
value={text}
|
||||
onChange={handleTextChange}
|
||||
onKeyDown={handleKeyDown}
|
||||
|
||||
@@ -575,6 +575,7 @@ const ConversationTabView = memo(function ConversationTabView({
|
||||
attachmentTabId={tabId}
|
||||
draftStorageKey={draftStorageKey}
|
||||
hideInput={isWelcomeMode}
|
||||
isActive={isActive}
|
||||
>
|
||||
{isWelcomeMode ? (
|
||||
<div className="flex h-full min-h-0 flex-col items-center justify-center">
|
||||
@@ -623,6 +624,7 @@ const ConversationTabView = memo(function ConversationTabView({
|
||||
availableCommands={connectionCommands}
|
||||
attachmentTabId={tabId}
|
||||
draftStorageKey={draftStorageKey}
|
||||
isActive={isActive}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user