mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
commit
6a16d31f26
1 changed files with 9 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { SSE } from '~/utils/sse';
|
import { SSE } from '~/utils/sse';
|
||||||
import SubmitButton from './SubmitButton';
|
import SubmitButton from './SubmitButton';
|
||||||
import Regenerate from './Regenerate';
|
import Regenerate from './Regenerate';
|
||||||
|
|
@ -14,6 +14,7 @@ import { setText } from '~/store/textSlice';
|
||||||
|
|
||||||
export default function TextChat({ messages }) {
|
export default function TextChat({ messages }) {
|
||||||
const [errorMessage, setErrorMessage] = useState('');
|
const [errorMessage, setErrorMessage] = useState('');
|
||||||
|
const inputRef = useRef(null)
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const convo = useSelector((state) => state.convo);
|
const convo = useSelector((state) => state.convo);
|
||||||
const { initial } = useSelector((state) => state.models);
|
const { initial } = useSelector((state) => state.models);
|
||||||
|
|
@ -22,6 +23,11 @@ export default function TextChat({ messages }) {
|
||||||
const { text } = useSelector((state) => state.text);
|
const { text } = useSelector((state) => state.text);
|
||||||
const { error } = convo;
|
const { error } = convo;
|
||||||
|
|
||||||
|
// auto focus to input, when enter a conversation.
|
||||||
|
useEffect(() => {
|
||||||
|
inputRef.current?.focus();
|
||||||
|
}, [convo?.conversationId, ])
|
||||||
|
|
||||||
const messageHandler = (data, currentState) => {
|
const messageHandler = (data, currentState) => {
|
||||||
const { messages, currentMsg, sender } = currentState;
|
const { messages, currentMsg, sender } = currentState;
|
||||||
dispatch(setMessages([...messages, currentMsg, { sender, text: data }]));
|
dispatch(setMessages([...messages, currentMsg, { sender, text: data }]));
|
||||||
|
|
@ -282,6 +288,8 @@ export default function TextChat({ messages }) {
|
||||||
<ModelMenu />
|
<ModelMenu />
|
||||||
<TextareaAutosize
|
<TextareaAutosize
|
||||||
tabIndex="0"
|
tabIndex="0"
|
||||||
|
autoFocus
|
||||||
|
ref={inputRef}
|
||||||
// style={{maxHeight: '200px', height: '24px', overflowY: 'hidden'}}
|
// style={{maxHeight: '200px', height: '24px', overflowY: 'hidden'}}
|
||||||
rows="1"
|
rows="1"
|
||||||
value={text}
|
value={text}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue