Skip to content

Commit

Permalink
fix: cannot redirect to project page for the first time (#155)
Browse files Browse the repository at this point in the history
<!-- 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 -->
  • Loading branch information
NarwhalChen authored Mar 5, 2025
1 parent 1173bef commit 90ebd1f
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 90ebd1f

Please sign in to comment.