Add correct history storage#11277
Open
e19166 wants to merge 1 commit intowso2:revamp-4.6.0from
Open
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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.
PR description
Summary
This PR improves how the chatbot conversation history is preserved when a user navigates between docs pages / versions. Before clearing the current chat session, the UI now snapshots the latest conversation and sends it to the parent docs page (when embedded in an iframe) so it can be stored as a saved session. It also updates the backend chat endpoint and removes unused authentication token handling.
Changes
latestMessagesRefand keeps it in sync withmessagesviauseEffect, ensuring the most recent conversation is always available even inside event handlers.chatHistoryfromlocalStorageor fallback to in-memory messages) and posts it to the parent window viawindow.parent.postMessage.type: 'chat-snapshot'id: 's_' + Date.now()state: { chatHistory: ... }try/catchso failures are non-fatal.localStorage.chatHistory, and reset UI state.authServiceimport and access-token retrieval.Authorization: Bearer ...header injection.fetchURL.Motivation / Problem
Previously, clearing
localStorageon navigation could cause the active conversation to be lost before the parent docs site had a chance to persist it as a saved session. This change ensures the current conversation is captured and handed off to the parent container before being cleared.