You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug: useParams hook not updating when URL changes from root path
Issue
When starting a new chat from the root path ('/'), the useParams hook in the sidebar doesn't detect the chat ID even after the URL changes to /chat/[id]. This creates a UI inconsistency where the active chat is not highlighted in the sidebar.
Reproduction Steps
Create a user and log-in
Start at root path ('/')
Begin a new chat
Send first message
URL changes to /chat/[id]
Sidebar fails to highlight the active chat because useParams returns undefined.
Sidebar fails to navigate back to root ('/') on the chat deletion.
Technical Details
To my understanding, the issue occurs due to how the chat creation flow works with the useChat hook from Vercel's AI SDK. The URL changes happen without triggering a full route change that useParams would detect.
From my understanding - this might be related to the useSWR, in useChat, but that was 2 deep of a dive for me RN 😆
Workaround
Added a fallback to extract the chat ID from pathname when useParams returns undefined at sidebar-history.tsx:
Bug: useParams hook not updating when URL changes from root path
Issue
When starting a new chat from the root path ('/'), the
useParams
hook in the sidebar doesn't detect the chat ID even after the URL changes to/chat/[id]
. This creates a UI inconsistency where the active chat is not highlighted in the sidebar.Reproduction Steps
/chat/[id]
useParams
returns undefined.Technical Details
To my understanding, the issue occurs due to how the chat creation flow works with the
useChat
hook from Vercel's AI SDK. The URL changes happen without triggering a full route change thatuseParams
would detect.From my understanding - this might be related to the useSWR, in useChat, but that was 2 deep of a dive for me RN 😆
Workaround
Added a fallback to extract the chat ID from pathname when
useParams
returns undefined at sidebar-history.tsx:The text was updated successfully, but these errors were encountered: