diff --git a/frontend/ChatLayout.tsx b/frontend/ChatLayout.tsx index a42c446..2076691 100644 --- a/frontend/ChatLayout.tsx +++ b/frontend/ChatLayout.tsx @@ -1,14 +1,63 @@ -import { SidebarProvider } from '@/frontend/components/ui/sidebar'; +import { + SidebarProvider, + SidebarTrigger, // Import SidebarTrigger for the Sidebar opening and closing + Sidebar, + SidebarInset, //Import SidebarInset as the main content wrapper + useSidebar, // Import useSidebar to conditionally render the trigger +} from '@/frontend/components/ui/sidebar'; + import ChatSidebar from '@/frontend/components/ChatSidebar'; import { Outlet } from 'react-router'; +import { Button } from '@/frontend/components/ui/button'; +import { PanelLeftIcon } from 'lucide-react'; +import { cn } from '@/lib/utils'; export default function ChatLayout() { return ( - -
- +
+ + + {/* + This is the global toggle button. + It's placed *outside* the ChatSidebar, ensuring it's always visible + even when the main sidebar is off-screen. + */} + + + +
); } + +/** + * A standalone component for the sidebar toggle button. + * It uses the sidebar context to determine its visibility and action. + * Renders fixed, ensuring it's always accessible. + */ +function GlobalSidebarToggleButton() { + const { toggleSidebar, open, isMobile } = useSidebar(); + + const isButtonVisible = isMobile || !open; + + if (!isButtonVisible) { + return null; + } + + return ( + + ); +} \ No newline at end of file