Skip to content

Commit 90ebd1f

Browse files
authored
fix: cannot redirect to project page for the first time (#155)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Improved chat session navigation for smoother transitions and a more integrated user experience. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 1173bef commit 90ebd1f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

frontend/src/components/sidebar.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
} from './ui/sidebar';
2121
import { cn } from '@/lib/utils';
2222
import { ProjectContext } from './chat/code-engine/project-context';
23+
import { useRouter } from 'next/navigation';
2324

2425
interface SidebarProps {
2526
setIsModalOpen: (value: boolean) => void; // Parent setter to update collapse state
@@ -57,6 +58,7 @@ export function ChatSideBar({
5758
const event = new Event(EventEnum.NEW_CHAT);
5859
window.dispatchEvent(event);
5960
}, []);
61+
const router = useRouter();
6062

6163
if (loading) return <SidebarSkeleton />;
6264
if (error) {
@@ -151,11 +153,7 @@ export function ChatSideBar({
151153
pollChatProject(chat.id).then((p) => {
152154
setCurProject(p);
153155
});
154-
window.history.replaceState(
155-
{},
156-
'',
157-
`/chat?id=${chat.id}`
158-
);
156+
router.push(`/chat?id=${chat.id}`);
159157
setCurrentChatid(chat.id);
160158
}}
161159
refetchChats={onRefetch}

0 commit comments

Comments
 (0)