Skip to content

Feature: Session history recovery API + localStorage persistence #14

Description

@anushagarg6

Description

The backend Redis session store survives server restarts and correctly stores conversation history per session. However there is no GET /api/session/<id> endpoint to retrieve this history, and the frontend stores all conversation data in a volatile in-memory object (const conversationStore = {} in chat.js).

Impact

Refreshing the browser wipes all chat history from the UI even though the data is still in Redis. Users cannot resume previous conversations after a page reload.

What Needs to Be Built

Backend (backend/app.py)

Add a new route:

@app.get("/api/session/{session_id}")
def get_session(session_id: str):
    history = get_history(session_id)
    return {"session_id": session_id, "history": history}

Frontend (frontend/js/chat.js)

  • Persist active sessionId to localStorage on first message
  • On page load, check localStorage for a saved session ID
  • If found, call GET /api/session/<id> to restore messages into the UI

Files Affected

  • backend/app.py
  • backend/sessions.py
  • frontend/js/chat.js

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions