From a4e38be3e33475c695870e7ff6916083b3b20a68 Mon Sep 17 00:00:00 2001 From: Lluis Agusti Date: Tue, 16 Dec 2025 18:49:49 +0100 Subject: [PATCH] chore: fixes --- .../app/(platform)/PlatformLayoutContent.tsx | 46 +++++++++++++++++++ .../frontend/src/app/(platform)/layout.tsx | 11 ++--- .../components/contextual/Chat/ChatDrawer.tsx | 10 +++- .../contextual/Chat/usePageContext.ts | 2 +- .../RunAgentInputs/RunAgentInputs.tsx | 14 ++++-- 5 files changed, 68 insertions(+), 15 deletions(-) create mode 100644 autogpt_platform/frontend/src/app/(platform)/PlatformLayoutContent.tsx diff --git a/autogpt_platform/frontend/src/app/(platform)/PlatformLayoutContent.tsx b/autogpt_platform/frontend/src/app/(platform)/PlatformLayoutContent.tsx new file mode 100644 index 0000000000..eb980e7dcf --- /dev/null +++ b/autogpt_platform/frontend/src/app/(platform)/PlatformLayoutContent.tsx @@ -0,0 +1,46 @@ +"use client"; + +import { ChatDrawer } from "@/components/contextual/Chat/ChatDrawer"; +import { usePathname } from "next/navigation"; +import { Children, ReactNode } from "react"; + +interface PlatformLayoutContentProps { + children: ReactNode; +} + +export function PlatformLayoutContent({ + children, +}: PlatformLayoutContentProps) { + const pathname = usePathname(); + const isAuthPage = + pathname?.includes("/login") || pathname?.includes("/signup"); + + // Extract Navbar, AdminImpersonationBanner, and page content from children + const childrenArray = Children.toArray(children); + const navbar = childrenArray[0]; + const adminBanner = childrenArray[1]; + const pageContent = childrenArray.slice(2); + + // For login/signup pages, use a simpler layout that doesn't interfere with centering + if (isAuthPage) { + return ( +
+ {navbar} + {adminBanner} +
{pageContent}
+
+ ); + } + + // For logged-in pages, use the drawer layout + return ( +
+ {navbar} + {adminBanner} +
+ {pageContent} +
+ +
+ ); +} diff --git a/autogpt_platform/frontend/src/app/(platform)/layout.tsx b/autogpt_platform/frontend/src/app/(platform)/layout.tsx index d5afc9ede0..3cb7283b53 100644 --- a/autogpt_platform/frontend/src/app/(platform)/layout.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/layout.tsx @@ -1,17 +1,14 @@ -import { ChatDrawer } from "@/components/contextual/Chat/ChatDrawer"; import { Navbar } from "@/components/layout/Navbar/Navbar"; import { ReactNode } from "react"; import { AdminImpersonationBanner } from "./admin/components/AdminImpersonationBanner"; +import { PlatformLayoutContent } from "./PlatformLayoutContent"; export default function PlatformLayout({ children }: { children: ReactNode }) { return ( -
+ -
- {children} -
- -
+ {children} + ); } diff --git a/autogpt_platform/frontend/src/components/contextual/Chat/ChatDrawer.tsx b/autogpt_platform/frontend/src/components/contextual/Chat/ChatDrawer.tsx index e91ca4bfd5..4dc79ece92 100644 --- a/autogpt_platform/frontend/src/components/contextual/Chat/ChatDrawer.tsx +++ b/autogpt_platform/frontend/src/components/contextual/Chat/ChatDrawer.tsx @@ -4,7 +4,7 @@ import { scrollbarStyles } from "@/components/styles/scrollbars"; import { cn } from "@/lib/utils"; import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag"; import { X } from "@phosphor-icons/react"; -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import { Drawer } from "vaul"; import { Chat } from "./Chat"; import { useChatDrawer } from "./useChatDrawer"; @@ -14,16 +14,22 @@ interface ChatDrawerProps { } export function ChatDrawer({ blurBackground = true }: ChatDrawerProps) { + const [isMounted, setIsMounted] = useState(false); const isChatEnabled = useGetFlag(Flag.CHAT); const { isOpen, close } = useChatDrawer(); + useEffect(() => { + setIsMounted(true); + }, []); + useEffect(() => { if (isChatEnabled === false && isOpen) { close(); } }, [isChatEnabled, isOpen, close]); - if (isChatEnabled === null || isChatEnabled === false) { + // Don't render on server - vaul drawer accesses document during SSR + if (!isMounted || isChatEnabled === null || isChatEnabled === false) { return null; } diff --git a/autogpt_platform/frontend/src/components/contextual/Chat/usePageContext.ts b/autogpt_platform/frontend/src/components/contextual/Chat/usePageContext.ts index ac7b7fb2d9..39f36ac941 100644 --- a/autogpt_platform/frontend/src/components/contextual/Chat/usePageContext.ts +++ b/autogpt_platform/frontend/src/components/contextual/Chat/usePageContext.ts @@ -10,7 +10,7 @@ export interface PageContext { */ export function usePageContext() { const capturePageContext = useCallback((): PageContext => { - if (typeof window === "undefined") { + if (typeof window === "undefined" || typeof document === "undefined") { return { url: "", content: "" }; } diff --git a/autogpt_platform/frontend/src/components/contextual/RunAgentInputs/RunAgentInputs.tsx b/autogpt_platform/frontend/src/components/contextual/RunAgentInputs/RunAgentInputs.tsx index 447a865d33..c450b48ee5 100644 --- a/autogpt_platform/frontend/src/components/contextual/RunAgentInputs/RunAgentInputs.tsx +++ b/autogpt_platform/frontend/src/components/contextual/RunAgentInputs/RunAgentInputs.tsx @@ -338,6 +338,7 @@ export function RunAgentInputs({ value={value ?? ""} onChange={(e) => onChange((e.target as HTMLInputElement).value)} placeholder={placeholder || "Enter text"} + disabled={readOnly} {...props} /> ); @@ -349,11 +350,14 @@ export function RunAgentInputs({ {schema.title || placeholder} -
- {innerInputElement} +
+ {readOnly ? ( +
+ {innerInputElement} +
+ ) : ( + innerInputElement + )}
);