Skip to content

fix(frontend): Implement localStorage persistence for chat session history (#45)#46

Open
SandeepChauhan00 wants to merge 1 commit intoINCF:mainfrom
SandeepChauhan00:fix/chat-session-persistence-45
Open

fix(frontend): Implement localStorage persistence for chat session history (#45)#46
SandeepChauhan00 wants to merge 1 commit intoINCF:mainfrom
SandeepChauhan00:fix/chat-session-persistence-45

Conversation

@SandeepChauhan00
Copy link

@SandeepChauhan00 SandeepChauhan00 commented Jan 30, 2026

🔗 Related Issue

Closes #45


📋 Summary

This PR implements persistent chat session history using localStorage, ensuring users don't lose their conversation when refreshing the page or accidentally closing the browser.


🐛 Problem

The current implementation intentionally clears all stored chat history on every page load, causing users to lose their conversation on refresh.

Impact:

  • Users lose entire conversation on page refresh (F5)
  • Research progress is lost unexpectedly
  • Poor user experience during long research sessions

✅ Solution

Feature Implementation
Load History getInitialMessages() restores saved conversations
Save History useEffect hook saves messages on state change
Date Handling Converts timestamp strings back to Date objects
Clear Function Updated to also clear localStorage

🔄 Changes Made

  • Removed code that clears localStorage on component mount
  • Added getInitialMessages() helper function
  • Added WELCOME_MESSAGE constant
  • Added useEffect hook to persist messages
  • Updated clearChat() function

🧪 Testing Performed

Test Case Result
Page refresh (F5) - messages persist ✅ Pass
Browser close/reopen - messages persist ✅ Pass
Clear button functionality ✅ Pass
Welcome message for new users ✅ Pass

✅ Checklist

@SandeepChauhan00
Copy link
Author

SandeepChauhan00 commented Feb 8, 2026

Hi @QuantumByte-01 @visakhmr! 👋

Checking in on this PR that implements session persistence. This fixes
Issue #45 where users lose their chat history on page refresh.

Implementation:
✅ localStorage-based session persistence
✅ Automatic restoration on page load
✅ Graceful handling of cleared/corrupted storage
✅ Maintains existing session API compatibility

This is a commonly requested feature that significantly improves UX.
All tasks are complete and ready for review.

Let me know if there are any concerns or if you'd like me to adjust
the approach. Thanks for your time! 🙏

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.

[Bug] Chat conversation history is lost on page refresh - No session persistence

1 participant