diff --git a/frontend/src/pages/CandidateChatPage.tsx b/frontend/src/pages/CandidateChatPage.tsx index 0f63c19..7c9b308 100644 --- a/frontend/src/pages/CandidateChatPage.tsx +++ b/frontend/src/pages/CandidateChatPage.tsx @@ -42,6 +42,7 @@ import { CandidateInfo } from 'components/CandidateInfo'; import { useNavigate } from 'react-router-dom'; import { useSelectedCandidate } from 'hooks/GlobalContext'; import PropagateLoader from 'react-spinners/PropagateLoader'; +import { BackstoryTextField, BackstoryTextFieldRef } from 'components/BackstoryTextField'; const DRAWER_WIDTH = 300; const FAB_WIDTH = 48; @@ -61,6 +62,7 @@ const CandidateChatPage = forwardRef((pr const isMdUp = useMediaQuery(theme.breakpoints.up('md')); const [processingMessage, setProcessingMessage] = useState(null); const [streamingMessage, setStreamingMessage] = useState(null); + const backstoryTextRef = useRef(null); const { setSnack, @@ -70,7 +72,6 @@ const CandidateChatPage = forwardRef((pr const [sessions, setSessions] = useState(null); const [chatSession, setChatSession] = useState(null); const [messages, setMessages] = useState([]); - const [newMessage, setNewMessage] = useState(''); const [loading, setLoading] = useState(false); const [streaming, setStreaming] = useState(false); const messagesEndRef = useRef(null); @@ -254,11 +255,10 @@ const CandidateChatPage = forwardRef((pr }; // Send message - const sendMessage = async () => { - if (!newMessage.trim() || !chatSession?.id || streaming) return; + const sendMessage = async (message: string) => { + if (!message.trim() || !chatSession?.id || streaming) return; - const messageContent = newMessage; - setNewMessage(''); + const messageContent = message; setStreaming(true); const chatMessage: ChatMessageUser = { @@ -446,7 +446,7 @@ const CandidateChatPage = forwardRef((pr cursor: 'pointer', backgroundColor: 'transparent', '&:hover': { - backgroundColor: chatSession?.id === session.id ? 'primary.light' : 'action.hover' + backgroundColor: 'action.hover' } }} secondaryAction={ @@ -668,26 +668,16 @@ const CandidateChatPage = forwardRef((pr {/* Fixed Message Input */} - setNewMessage(e.target.value)} - onKeyDown={(e) => { - if (e.key === 'Enter' && !e.shiftKey) { - e.preventDefault(); - sendMessage(); - } - }} + ref={backstoryTextRef} + onEnter={sendMessage} disabled={streaming} - multiline - maxRows={4} />