Skip to content

AlgoBot Has No Persistent Chat History Across Navigation #14

Description

@Rishabhworkspace

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" ClickedlocalStorage history is removed. The UI resets to the welcome/empty state.

Tasks

  • Identify the messages state in AlgoBot.tsx.
  • On each new message, serialize the last 20 messages to localStorage under key algobot_history.
  • On component mount, read from localStorage and pre-populate the messages state.
  • Add a "Clear Chat" button in the AlgoBot header that clears localStorage and resets state.
  • Wrap localStorage access in a try/catch to handle private browsing environments.

Acceptance Criteria

  • Chat history persists across page navigation and browser refresh.
  • History is capped at 20 messages.
  • "Clear Chat" removes history from localStorage and resets the UI to the empty state.
  • No errors occur when localStorage is unavailable.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions