Add cleanup function to setTimeout in useEffect to prevent memory leaks

Co-authored-by: GTheMachine <156854865+GTheMachine@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-10 22:42:17 +00:00
parent 7886a29089
commit a4dc21fd84

View File

@@ -100,9 +100,10 @@ export function InterviewView() {
// Auto-scroll to bottom when messages change
useEffect(() => {
let timeoutId: NodeJS.Timeout | undefined;
if (messagesContainerRef.current) {
// Use a small delay to ensure DOM is updated
setTimeout(() => {
timeoutId = setTimeout(() => {
if (messagesContainerRef.current) {
messagesContainerRef.current.scrollTo({
top: messagesContainerRef.current.scrollHeight,
@@ -111,6 +112,11 @@ export function InterviewView() {
}
}, 100);
}
return () => {
if (timeoutId) {
clearTimeout(timeoutId);
}
};
}, [messages]);
// Auto-focus input