---
phase: 06-web-chat
plan: 03
type: execute
wave: 2
depends_on: ["06-01", "06-02"]
files_modified: []
autonomous: false
requirements:
  - CHAT-01
  - CHAT-02
  - CHAT-03
  - CHAT-04
  - CHAT-05

must_haves:
  truths:
    - "End-to-end chat works: user sends message via WebSocket, receives LLM response"
    - "Conversation history persists and loads on page revisit"
    - "Typing indicator appears during response generation"
    - "Markdown renders correctly in agent responses"
    - "RBAC enforced: operator can chat, but cannot see admin-only nav items"
    - "Platform admin can chat with agents across tenants"
  artifacts: []
  key_links: []
---

<objective>
Human verification of the complete web chat feature. Test end-to-end flow, RBAC enforcement, conversation persistence, and UX quality.

Purpose: Confirm all CHAT requirements are met before marking Phase 6 complete.
Output: Verified working chat feature.
</objective>

<execution_context>
@/home/adelorenzo/.claude/get-shit-done/workflows/execute-plan.md
@/home/adelorenzo/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/phases/06-web-chat/06-01-SUMMARY.md
@.planning/phases/06-web-chat/06-02-SUMMARY.md
</context>

<tasks>

<task type="checkpoint:human-verify" gate="blocking">
  <name>Task 1: Verify end-to-end web chat feature</name>
  <files></files>
  <action>
    Present the following verification checklist to the user. This is a human verification checkpoint — no code changes needed.

    What was built:
    - WebSocket-based real-time chat in the portal at /chat
    - Conversation sidebar with agent list, timestamps, message previews
    - Message bubbles with markdown rendering and typing indicators
    - Full agent pipeline integration (memory, tools, escalation, audit)
    - Conversation history persistence in PostgreSQL
    - RBAC enforcement (all roles can chat, scoped to accessible tenants)

    Prerequisites:
    - Docker Compose stack running (gateway, orchestrator, portal, postgres, redis)
    - At least one active agent configured for a tenant
    - Migration applied: `alembic upgrade head`

    Test 1 — Basic Chat (CHAT-01, CHAT-05):
    1. Log in to portal as customer_admin
    2. Click "Chat" in the sidebar navigation
    3. Click "New Conversation" and select an AI Employee
    4. Type a message and press Enter
    5. Verify: typing indicator (animated dots) appears immediately
    6. Verify: agent response appears as a left-aligned message bubble
    7. Verify: your message appears right-aligned

    Test 2 — Markdown Rendering (CHAT-05):
    1. Send a message that triggers a formatted response (e.g., "Give me a bulleted list of 3 tips")
    2. Verify: response renders with proper markdown (bold, lists, code blocks)

    Test 3 — Conversation History (CHAT-03):
    1. After sending a few messages, navigate away from /chat (e.g., go to /dashboard)
    2. Navigate back to /chat
    3. Verify: previous conversation appears in sidebar with last message preview
    4. Click the conversation
    5. Verify: full message history loads (all previous messages visible)

    Test 4 — RBAC (CHAT-04):
    1. Log in as customer_operator
    2. Verify: "Chat" link visible in sidebar
    3. Navigate to /chat, start a conversation with an agent
    4. Verify: chat works (operators can chat)
    5. Verify: admin-only nav items (Billing, API Keys, Users) are still hidden

    Test 5 — Full Pipeline (CHAT-02):
    1. If the agent has tools configured, send a message that triggers tool use
    2. Verify: agent invokes the tool and incorporates the result
    3. (Optional) If escalation rules are configured, trigger one and verify handoff message
  </action>
  <verify>Human confirms all 5 test scenarios pass</verify>
  <done>User types "approved" confirming end-to-end web chat works correctly across all CHAT requirements</done>
</task>

</tasks>

<verification>
All 5 test scenarios pass as described above.
</verification>

<success_criteria>
- Human confirms end-to-end chat works with real LLM responses
- Conversation history persists across page navigations
- Typing indicator visible during response generation
- Markdown renders correctly
- RBAC correctly scopes agent access
- All three roles (platform_admin, customer_admin, customer_operator) can chat
</success_criteria>

<output>
After completion, create `.planning/phases/06-web-chat/06-03-SUMMARY.md`
</output>
