From f2ead70f3d72c9a43cd8716e78941059cf594959 Mon Sep 17 00:00:00 2001 From: Ubbe Date: Tue, 10 Feb 2026 21:39:11 +0800 Subject: [PATCH] fix(frontend): copilot redirect logout (#12050) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Changes 🏗️ Redirect to `/login` if the user is not authenticated and tries to access `/copilot` ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Run the app locally and tested --- .../frontend/src/app/(platform)/copilot/useCopilotPage.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts index 3dbba6e790..c480ce13b9 100644 --- a/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts +++ b/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotPage.ts @@ -3,6 +3,7 @@ import { useBreakpoint } from "@/lib/hooks/useBreakpoint"; import { useSupabase } from "@/lib/supabase/hooks/useSupabase"; import { useChat } from "@ai-sdk/react"; import { DefaultChatTransport } from "ai"; +import { useRouter } from "next/navigation"; import { useEffect, useMemo, useState } from "react"; import { useChatSession } from "./useChatSession"; @@ -10,6 +11,7 @@ export function useCopilotPage() { const { isUserLoading, isLoggedIn } = useSupabase(); const [isDrawerOpen, setIsDrawerOpen] = useState(false); const [pendingMessage, setPendingMessage] = useState(null); + const router = useRouter(); const { sessionId, @@ -52,6 +54,10 @@ export function useCopilotPage() { transport: transport ?? undefined, }); + useEffect(() => { + if (!isUserLoading && !isLoggedIn) router.replace("/login"); + }, [isUserLoading, isLoggedIn]); + useEffect(() => { if (!hydratedMessages || hydratedMessages.length === 0) return; setMessages((prev) => {