# Milestone 2.1 — Visitor & Agent WebSocket Presence Foundation

This directory documents the implementation of **Milestone 2, Step 2.1: Visitor & Agent WebSocket Presence Foundation**.

---

## Documents in this folder

- **[01-websocket-presence.md](file:///c:/Users/alokc/chatbot/backend/docs/learning/m2-1-websocket-presence/01-websocket-presence.md)** — Explains WebSocket concepts, dual visitor/agent feeds, presence lifecycle, and the `active_sessions` state store.
- **[02-m2-1-revision.md](file:///c:/Users/alokc/chatbot/backend/docs/learning/m2-1-websocket-presence/02-m2-1-revision.md)** — Short revision summary and test suite verification.

---

## How to Verify Milestone 2.1

1. **Run Backend Test Suite:**
   ```bash
   cd backend
   .\venv\Scripts\python.exe -m pytest
   ```
   *Verifies 22 passing unit tests across CORS, Tenant, Session, Message, Handoff, and WebSocket modules.*

2. **Manual Verification:**
   - **Start Backend:** `uvicorn app.main:app --reload --port 8000`
   - **Open Dashboard:** Open `http://localhost:8000/admin` in browser. Shows "WS Feed: Connected".
   - **Open Visitor Widget:** Open `widget/demo.html`.
   - **Verify Presence Event:** Agent dashboard rings chime sound and displays new visitor card with `RINGING` badge.
