fix(ui): Set page title

This commit is contained in:
Richard Palethorpe
2025-04-02 08:23:12 +01:00
parent 9f77bb99f1
commit 6d9f1a95cc
10 changed files with 88 additions and 36 deletions

View File

@@ -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' });