Realtime & SSE
KanbanAI uses Server-Sent Events (SSE) as the real-time interface. SSE provides a simpler HTTP-based approach with automatic reconnection, better proxy support, and no special protocol handling. HTTP remains the source of truth; real-time interfaces push incremental updates and events so clients rarely need to refetch.Endpoints
Server-Sent Events (SSE)
- Board channel:
GET /api/v1/sse?boardId=<boardId>– per-board SSE stream.boardIdmay also be passed asprojectIdfor compatibility.- Requires
boardIdquery parameter.
- Dashboard channel:
GET /api/v1/sse– global dashboard SSE stream (no boardId required).
Board channel
- Connection:
- Client connects with
boardIdin the query string. - Server validates access, then:
- Sends an initial
hellomessage ({"event":"hello","data":{"serverTime":"<ISO 8601>"}}). - Sends a
statepayload with the current board snapshot (columns + cards + attempts).- Each card record carries
isEnhancedso clients know which cards should render the persistent “Enhanced” badge/highlight.
- Each card record carries
- Sends an initial
- Client connects with
- Events:
- SSE listeners subscribe to domain events and broadcast updates:
board.state.changedattempt.*git.*github.pr.createdagent.profile.changed,agent.registered
- Messages are shaped according to
shared/src/types/kanban.tsand include enough data for the client to update local state without refetching. - Card envelopes include
isEnhancedanddisableAutoCloseOnPRMergeso badges and auto-close opt-outs stay in sync with real-time updates.
- SSE listeners subscribe to domain events and broadcast updates:
- Heartbeats:
- Server sends
heartbeatevents every 15 seconds to keep connections alive. - Client uses exponential backoff (1.5s base, max 12s, up to 8 attempts) for reconnection.
- Server sends
Dashboard channel
- Connection:
- Single global endpoint at
/api/v1/sse(no query parameters). - On connect, the server:
- Sends a
helloenvelope ({"event":"hello","data":{"serverTime":"<ISO 8601>"}}). - Immediately follows with the current
dashboard_overviewenvelope ({"event":"dashboard_overview","data": ... }) that mirrors the HTTPDashboardOverview(metrics, active attempts, inbox items, recent activity, project snapshots, and agent stats). - The
dashboard_overviewpayload includes normalizedtimeRangeandmeta(the same metadata object withversionandavailableTimeRangePresets) so both HTTP and SSE clients share the same shape.
- Sends a
- Single global endpoint at
- Updates:
- The SSE stream is read-only.
- When relevant events occur (e.g. attempts complete, boards change), listeners recompute the overview and push an updated snapshot down the stream.
- Heartbeats:
- Server sends
heartbeatevents every 15 seconds.
- Server sends
Error handling & fallbacks
- SSE uses standard HTTP, making it available in most environments including those with restrictive proxies.
- Clients should:
- Treat real-time connections as best-effort.
- Fall back to periodic HTTP refreshes (e.g. refetch board or dashboard queries) when the real-time connection is unavailable.
Security & CORS
- SSE shares the same origin/host/port as the HTTP API.
- Security headers and CORS are applied to HTTP endpoints including SSE:
/api/*routes use CORS for REST.- SSE endpoints are standard HTTP and receive full CORS support.
Event Types Reference
| Event | Description |
|---|---|
hello | Initial connection acknowledgment with server timestamp |
state | Full board state snapshot |
heartbeat | Keep-alive signal (every 15s) |
attempt_started | New attempt initiated for a card |
attempt_status | Attempt status changed |
attempt_log | Log message from attempt |
conversation_item | New conversation message in attempt |
attempt_session | Worktree session recorded |
attempt_todos | Attempt todo list updated |
git_status | Git status changed |
git_commit | New commit created |
git_push | Changes pushed to remote |
attempt_pr | Pull request created from attempt |
agent_profile | Agent profile created/updated/deleted |
agent_registered | New agent registered |
terminal_opened | Terminal session opened for a card |
terminal_closed | Terminal session closed |
dashboard_overview | Dashboard metrics snapshot (dashboard channel) |
core/kanban-boards-and-tasks.mdcore/ai-attempts.mdcore/git-integration.md