2026-01-17 11:02:33 +08:00
|
|
|
"use client";
|
|
|
|
|
|
2026-01-21 10:31:54 +08:00
|
|
|
import { usePathname } from "next/navigation";
|
|
|
|
|
import { useTheme } from "next-themes";
|
|
|
|
|
import { useMemo } from "react";
|
|
|
|
|
|
|
|
|
|
import { FlickeringGrid } from "@/components/ui/flickering-grid";
|
2026-01-17 11:02:33 +08:00
|
|
|
import { ArtifactsProvider } from "@/components/workspace/artifacts";
|
|
|
|
|
|
|
|
|
|
export default function ChatLayout({
|
|
|
|
|
children,
|
|
|
|
|
}: {
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
}) {
|
2026-01-21 10:31:54 +08:00
|
|
|
const pathname = usePathname();
|
|
|
|
|
const isNewThread = useMemo(() => {
|
|
|
|
|
return pathname === "/workspace/chats/new";
|
|
|
|
|
}, [pathname]);
|
2026-01-21 10:48:29 +08:00
|
|
|
const { resolvedTheme } = useTheme();
|
2026-01-21 10:31:54 +08:00
|
|
|
return (
|
|
|
|
|
<ArtifactsProvider>
|
|
|
|
|
{isNewThread && (
|
|
|
|
|
<>
|
|
|
|
|
<FlickeringGrid
|
|
|
|
|
className="absolute inset-0 z-0 translate-y-[2vh] mask-center mask-no-repeat"
|
|
|
|
|
squareSize={4}
|
|
|
|
|
gridGap={4}
|
2026-01-21 10:35:50 +08:00
|
|
|
color={
|
2026-01-21 10:48:29 +08:00
|
|
|
resolvedTheme === "dark" ? "#60A5FA" : "oklch(0 0.0098 87.47)"
|
2026-01-21 10:35:50 +08:00
|
|
|
}
|
2026-01-22 13:50:09 +08:00
|
|
|
maxOpacity={resolvedTheme === "dark" ? 0.04 : 0.015}
|
2026-01-21 10:31:54 +08:00
|
|
|
flickerChance={0.1}
|
|
|
|
|
/>
|
|
|
|
|
<FlickeringGrid
|
|
|
|
|
className="absolute inset-0 z-0 translate-y-[2vh] mask-[url(/images/deer.svg)] mask-size-[100vw] mask-center mask-no-repeat md:mask-size-[72vh]"
|
|
|
|
|
squareSize={4}
|
|
|
|
|
gridGap={4}
|
2026-01-21 10:35:50 +08:00
|
|
|
color={
|
2026-01-21 10:48:29 +08:00
|
|
|
resolvedTheme === "dark" ? "#60A5FA" : "oklch(0 0.0098 87.47)"
|
2026-01-21 10:35:50 +08:00
|
|
|
}
|
2026-01-22 13:50:09 +08:00
|
|
|
maxOpacity={resolvedTheme === "dark" ? 0.15 : 0.075}
|
2026-01-21 10:31:54 +08:00
|
|
|
flickerChance={0.12}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
{children}
|
|
|
|
|
</ArtifactsProvider>
|
|
|
|
|
);
|
2026-01-17 11:02:33 +08:00
|
|
|
}
|