From 0833d6b4776aa6ecb766529ee85e1a12130efca8 Mon Sep 17 00:00:00 2001 From: Narwhal Date: Tue, 4 Mar 2025 18:00:28 -0600 Subject: [PATCH] fix: cannot redirect to project page for the first time --- frontend/src/components/sidebar.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/sidebar.tsx b/frontend/src/components/sidebar.tsx index 04939509..7f5c4311 100644 --- a/frontend/src/components/sidebar.tsx +++ b/frontend/src/components/sidebar.tsx @@ -20,6 +20,7 @@ import { } from './ui/sidebar'; import { cn } from '@/lib/utils'; import { ProjectContext } from './chat/code-engine/project-context'; +import { useRouter } from 'next/navigation'; interface SidebarProps { setIsModalOpen: (value: boolean) => void; // Parent setter to update collapse state @@ -57,6 +58,7 @@ export function ChatSideBar({ const event = new Event(EventEnum.NEW_CHAT); window.dispatchEvent(event); }, []); + const router = useRouter(); if (loading) return ; if (error) { @@ -151,11 +153,7 @@ export function ChatSideBar({ pollChatProject(chat.id).then((p) => { setCurProject(p); }); - window.history.replaceState( - {}, - '', - `/chat?id=${chat.id}` - ); + router.push(`/chat?id=${chat.id}`); setCurrentChatid(chat.id); }} refetchChats={onRefetch}