import PageSuspense from "@/components/PageSuspense"; import { useAIDrawer } from "@/contexts/AIDrawerContext"; import { useIsLgUp } from "@/hooks/useIsLgUp"; import { cn } from "@/lib/utils"; import { useLocation } from "wouter"; import { useCallback, useEffect, useRef, lazy, type ReactNode, type RefObject, } from "react"; const AIPage = lazy(() => import("@/pages/AIPage")); function SplitDivider({ containerRef, onResize, }: { containerRef: RefObject; onResize: (aiPercent: number) => void; }) { const dragging = useRef(false); const onMove = useCallback( (e: MouseEvent) => { if (!dragging.current || !containerRef.current) return; const r = containerRef.current.getBoundingClientRect(); const w = r.width; if (w <= 0) return; const aiPct = ((r.right - e.clientX) / w) * 100; onResize(aiPct); }, [containerRef, onResize], ); useEffect(() => { const onUp = () => { dragging.current = false; }; window.addEventListener("mouseup", onUp); window.addEventListener("mousemove", onMove); return () => { window.removeEventListener("mouseup", onUp); window.removeEventListener("mousemove", onMove); }; }, [onMove]); return (
{ dragging.current = true; }} role="separator" aria-orientation="vertical" aria-label="Resize panels" >
); } const isLegacyBuild = import.meta.env.VITE_X8_LEGACY === "1"; /** * lg+: optional side-by-side AI panel with draggable divider. Mobile unchanged (router only). */ export default function DesktopAIShell({ children }: { children: ReactNode }) { const isLgUp = useIsLgUp(); const [location] = useLocation(); const { open, setOpen, splitPercent, setSplitPercent } = useAIDrawer(); const containerRef = useRef(null); const showSplit = Boolean(isLgUp && open && location !== "/ai"); useEffect(() => { if (location === "/ai" && isLgUp) setOpen(false); }, [location, isLgUp, setOpen]); return (
{children}
{showSplit && ( <> setSplitPercent(aiPct)} />
setOpen(false)} />
)}
); }