// ChatLayout.jsx import React, { useState, useEffect } from "react"; import ChatHeader from "./ChatHeader"; import ChatWindow from "./ChatWindow"; import ChatInput from "./ChatInput"; import SessionTable from "./SessionTable"; export default function ChatLayout({ theme, messages, loading, onSend, onStop, onToggleTheme, onReloadHistory, onFreshStart, onCreateSession, onEditSession, onSelectSession, userId }) { const [showSessionsPanel, setShowSessionsPanel] = useState(false); // 1️⃣ helper at the top (inside the component is fine) function getScrollbarWidth() { return window.innerWidth - document.documentElement.clientWidth; } // update body class when panel state changes useEffect(() => { document.body.classList.toggle("sessions-open", showSessionsPanel); }, [showSessionsPanel]); // 2️⃣ revised toggles const openSessionManager = () => { const scrollBarWidth = getScrollbarWidth(); document.body.style.overflow = "hidden"; document.body.style.paddingRight = `${scrollBarWidth}px`; setShowSessionsPanel(true); }; const closeSessionManager = () => { document.body.style.overflow = ""; document.body.style.paddingRight = ""; setShowSessionsPanel(false); document.body.classList.remove("sessions-open"); // extra sicurezza }; return ( <>
{loading && (
)}
Manage Sessions
); }