Description
AlgoBot's conversation history is held entirely in local React component state. Every time the user navigates to a different section and returns, or refreshes the page, the entire chat history is wiped. Users who are mid-conversation with the bot lose all context and must start over. There is also no way to clear the history intentionally.
Requirements
- Persist the last 20 chat messages to
localStorage on each new message (keyed by session/user).
- Restore chat history from
localStorage on component mount.
- Cap the stored history at 20 messages to prevent unbounded storage growth.
- Add a "Clear Chat" button in the AlgoBot header.
- Handle
localStorage unavailability gracefully (private browsing mode).
Expected Behavior
Page Refresh or Navigation — The last 20 messages are restored when AlgoBot is reopened. The conversation continues from where the user left off.
"Clear Chat" Clicked — localStorage history is removed. The UI resets to the welcome/empty state.
Tasks
Acceptance Criteria
Description
AlgoBot's conversation history is held entirely in local React component state. Every time the user navigates to a different section and returns, or refreshes the page, the entire chat history is wiped. Users who are mid-conversation with the bot lose all context and must start over. There is also no way to clear the history intentionally.
Requirements
localStorageon each new message (keyed by session/user).localStorageon component mount.localStorageunavailability gracefully (private browsing mode).Expected Behavior
Page Refresh or Navigation — The last 20 messages are restored when AlgoBot is reopened. The conversation continues from where the user left off.
"Clear Chat" Clicked —
localStoragehistory is removed. The UI resets to the welcome/empty state.Tasks
AlgoBot.tsx.localStorageunder keyalgobot_history.localStorageand pre-populate the messages state.localStorageand resets state.localStorageaccess in a try/catch to handle private browsing environments.Acceptance Criteria
localStorageand resets the UI to the empty state.localStorageis unavailable.