#941 — Refactor existing websocket backend
Repo: Twill-AI/facade State: closed | Status: done Assignee: meliascosta, nadddder
Created: 2026-01-22 · Updated: 2026-01-23
Description
Update the existing /api/v1/ws websocket to work with the new partner/merchant site. Add a lightweight v2 protocol with topic subscriptions and broadcast DbActivity changes (including agent-created activities) to subscribed clients. Improve local/dev usability (CORS + client tool) and harden WS connect flow.
AC
- Auth: Partner/merchant and legacy tenant users can successfully call GET /api/v1/ws and connect to WS /api/v1/ws/{ticket_id} (ticket TTL + single-use preserved).
- Protocol: On connect, server sends SessionHello. Client can send Subscribe/Unsubscribe and receive Ack/Error.
- Subscriptions: Topics partner:{partner_id} and merchant:{merchant_id} are supported, with server-side authorization enforced (partner scope/assigned merchants; merchant-only self).
- Broadcasting: New/updated DbActivity records are pushed as ActivityEvent to subscribed sessions via: activity tracking (track_activity_on_change) system message update path (agent/master update endpoint)
- Dev tooling: tools/client_ws.html can fetch a ticket with a Bearer token, connect, subscribe, and display ActivityEvents.
Notes
Add implementation notes, blockers, and context here
Related
Add wikilinks to related people, meetings, or other tickets