-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: cannot redirect to project page for the first time #155
Conversation
WalkthroughThe change updates the navigation mechanism in the sidebar component by replacing the manual history API with Next.js routing. Instead of using Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant SB as Sidebar Component
participant R as Next.js Router
participant CP as Chat Page
U->>SB: Select chat session
SB->>R: Call router.push(`/chat?id=${chat.id}`)
R->>CP: Render chat page with selected chat
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
frontend/src/components/sidebar.tsxOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct. The config "next/core-web-vitals" was referenced from the config file in "/frontend/.eslintrc.json". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/src/components/sidebar.tsx (1)
55-57
: Consider using router.push for consistency in handleNewChat.While you've correctly updated the chat selection navigation to use Next.js routing, the
handleNewChat
function still uses the direct history API. For consistency and to prevent similar issues, consider using the router here as well.const handleNewChat = useCallback(() => { - window.history.replaceState({}, '', '/'); + router.push('/'); setCurrentChatid(''); const event = new Event(EventEnum.NEW_CHAT); window.dispatchEvent(event); }, []);Note: Don't forget to add
router
to the dependency array ofuseCallback
.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/components/sidebar.tsx
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Install and Build Frontend
🔇 Additional comments (3)
frontend/src/components/sidebar.tsx (3)
23-23
: Good addition of Next.js routing capabilities.Adding the useRouter import from next/navigation is the correct approach for implementing client-side navigation in Next.js applications.
61-61
: Proper initialization of the router hook.The router is correctly initialized at the component's top level as required for React hooks.
156-156
: Improved navigation mechanism fixes the redirect issue.Replacing the previous
window.history.replaceState
approach withrouter.push
is the correct solution to fix the redirect issue. This change ensures proper navigation to the project page by triggering a full route change rather than just updating the URL.
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> - **Refactor** - Improved chat session navigation for smoother transitions and a more integrated user experience. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> - **Refactor** - Improved chat session navigation for smoother transitions and a more integrated user experience. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit