Merge pull request #27 from vgcman16/codex/investigate-rerender-issue-with-navigation-function

Document navigation workaround
This commit is contained in:
vgcman16 2025-06-05 21:06:04 -05:00 committed by GitHub
commit 10d192667a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -400,9 +400,12 @@ ${value.content}
function navigateChat(nextId: string) {
/**
* FIXME: Using the intended navigate function causes a rerender for <Chat /> that breaks the app.
* We intentionally avoid using Remix's `navigate` helper here.
*
* `navigate(`/chat/${nextId}`, { replace: true });`
* Calling `navigate(`/chat/${nextId}`, { replace: true })` triggers a full
* route transition. That unmounts `<Chat />` which loses the in-memory chat
* state and results in a broken UI. Updating the history directly keeps the
* component mounted while still reflecting the new chat ID in the URL.
*/
const url = new URL(window.location.href);
url.pathname = `/chat/${nextId}`;