Skip to content

Add correct history storage#11277

Open
e19166 wants to merge 1 commit intowso2:revamp-4.6.0from
e19166:revamp-4.6.0
Open

Add correct history storage#11277
e19166 wants to merge 1 commit intowso2:revamp-4.6.0from
e19166:revamp-4.6.0

Conversation

@e19166
Copy link
Copy Markdown
Contributor

@e19166 e19166 commented Apr 30, 2026

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

  • Add “latest messages” snapshot tracking
    • Introduces latestMessagesRef and keeps it in sync with messages via useEffect, ensuring the most recent conversation is always available even inside event handlers.
  • Snapshot chat history before clearing
    • On navigation/hash change cleanup, captures current chat state (chatHistory from localStorage or fallback to in-memory messages) and posts it to the parent window via window.parent.postMessage.
    • Message payload:
      • type: 'chat-snapshot'
      • id: 's_' + Date.now()
      • state: { chatHistory: ... }
    • Wrapped in try/catch so failures are non-fatal.
  • Clear local history as before
    • Continues to abort any inflight request, clear localStorage.chatHistory, and reset UI state.
  • Remove auth token usage
    • Deletes authService import and access-token retrieval.
    • Removes conditional Authorization: Bearer ... header injection.
  • Update chat service endpoint
    • Switches the fetch URL.

Motivation / Problem

Previously, clearing localStorage on 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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bee7975a-e631-442d-8167-e10fdd74f99e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant