Skip to content

Commit

Permalink
fix: cannot redirect to project page for the first time
Browse files Browse the repository at this point in the history
  • Loading branch information
NarwhalChen committed Mar 5, 2025
1 parent b616285 commit 0833d6b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions frontend/src/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -57,6 +58,7 @@ export function ChatSideBar({
const event = new Event(EventEnum.NEW_CHAT);
window.dispatchEvent(event);
}, []);
const router = useRouter();

if (loading) return <SidebarSkeleton />;
if (error) {
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 0833d6b

Please sign in to comment.