fix(ui): Set page title
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { useState, useRef, useEffect } from 'react';
|
||||
import { useParams, useOutletContext } from 'react-router-dom';
|
||||
import { useParams, useOutletContext, useNavigate } from 'react-router-dom';
|
||||
import { useChat } from '../hooks/useChat';
|
||||
|
||||
function Chat() {
|
||||
const { name } = useParams();
|
||||
const { showToast } = useOutletContext();
|
||||
const navigate = useNavigate();
|
||||
const [message, setMessage] = useState('');
|
||||
const messagesEndRef = useRef(null);
|
||||
|
||||
@@ -19,6 +20,16 @@ function Chat() {
|
||||
clearError
|
||||
} = useChat(name);
|
||||
|
||||
// Update document title
|
||||
useEffect(() => {
|
||||
if (name) {
|
||||
document.title = `Chat with ${name} - LocalAgent`;
|
||||
}
|
||||
return () => {
|
||||
document.title = 'LocalAgent'; // Reset title when component unmounts
|
||||
};
|
||||
}, [name]);
|
||||
|
||||
// Scroll to bottom when messages change
|
||||
useEffect(() => {
|
||||
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
||||
|
||||
Reference in New Issue
Block a user