fix(web): clear stale conversation_id from localStorage on 404 - #39593
Open
6mvp6 wants to merge 4 commits into
Open
fix(web): clear stale conversation_id from localStorage on 404#395936mvp6 wants to merge 4 commits into
6mvp6 wants to merge 4 commits into
Conversation
6mvp6
requested review from
CodingOnStar,
hyoban,
iamjoel and
zxhlyh
as code owners
July 26, 2026 12:04
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an infinite 404 retry loop in the web chatbot when a stale conversation_id is persisted in localStorage, by making the shared chat-list query stop retrying on 404 and clearing the stored conversation ID so the UI can fall back to starting a new conversation.
Changes:
- Disable TanStack Query retries specifically for 404s in
useShareChatList. - Consume the
errorstate in the embedded chatbot and chat-with-history hooks; on 404, clear the persistedconversationIdInfo. - Add hook tests to assert
conversationIdInfois cleared when chat list fetch returns 404.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| web/service/use-share.ts | Disables retries for 404 responses in useShareChatList while keeping default retry behavior for other errors. |
| web/service/share.ts | Makes fetchChatList silent (suppresses toasts) for stale-conversation 404s. |
| web/app/components/base/chat/embedded-chatbot/hooks.tsx | Clears stale conversationIdInfo on 404 by consuming useShareChatList error state. |
| web/app/components/base/chat/embedded-chatbot/tests/hooks.spec.tsx | Adds test verifying localStorage is cleared on 404. |
| web/app/components/base/chat/chat-with-history/hooks.tsx | Adds 404 recovery by clearing stale conversationIdInfo (plus helper). |
| web/app/components/base/chat/chat-with-history/tests/hooks.spec.tsx | Adds test verifying localStorage is cleared on 404. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Author
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #39484.
When a
conversation_idpersisted inlocalStoragebecomes stale (conversation deleted server-side, or end-user identity changed), the Web App chatbot had no 404 recovery path:useShareChatListretried indefinitely, the error state was never consumed, andremoveConversationIdInfo()was never called — trapping the user in an infinite 404 loop onGET /api/messages, with the only workaround being to manually clear site data.This is the same issue as #34731 (closed, fix never released) and the same fix strategy as #34945 (open, but conflicting + stale CI), rebased onto current
main(which has since refactored the localStorage layer intouseConversationIdInfo).Changes (all frontend):
web/service/use-share.ts—useShareChatListdisables retries for 404 (other errors keep default 3).embedded-chatbot/hooks.tsx— consume theerrorfromuseShareChatList; on 404 clear the stale id via the existingremoveConversationIdInfo.chat-with-history/hooks.tsx— same, plus a matchingremoveConversationIdInfohelper.Tests: added a case to each hook's
hooks.spec.tsxasserting the staleconversationIdInfoentry is removed when the chat list returns 404.Verified locally:
pnpm type-check,pnpm lint:oxlint(0 errors), and the relevant vitest suites pass (embedded: 36 passed, chat-with-history: 66 passed).