feat(monitor): WS client live stream + apply snapshot/delta to UI
Hand-rolled minimal RFC6455 WebSocket client (~330 LOC) tailored to the
Monitor tab's needs. Single endpoint, text frames, masked client→server,
exponential reconnect backoff (0.5s → 8s cap), thread-safe in/out queues.
TLS is intentionally out of scope (localhost-only). Sec-WebSocket-Accept
verification is skipped — the server is controlled, 101 status is enough.
Files:
- ws_client.{h,cpp}: WsClient with start(host,port,path), drain(), send_text(),
is_connected(), last_event_ts(). Worker thread does connect + handshake +
read_loop + reconnect.
- CMakeLists.txt: pulls ws_client.cpp into the dashboard target. ws2_32 was
already linked for http_client.cpp.
- main.cpp: parses host:port from --api URL, spawns a global WsClient, and
drains its queue once per render frame via poll_ws(). apply_ws_message()
routes JSON to g_data.claude:
snapshot → replace KPIs + recent_executions
delta → append rows, increment total_calls / total_errors
monitor_set_ws_state() forwards connection state + last_event_ts to the
Monitor toolbar LED.
End-to-end smoke test passed against sqlite_api on localhost:8484:
- Snapshot received with KPIs + 100 recent rows.
- After INSERT INTO calls, delta arrives within ~250ms (server ticker).
- Errors (success=0) propagate correctly and bump the Errors KPI.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ add_imgui_app(registry_dashboard
|
||||
data.cpp
|
||||
data_http.cpp
|
||||
http_client.cpp
|
||||
ws_client.cpp
|
||||
views.cpp
|
||||
${CMAKE_SOURCE_DIR}/functions/viz/kpi_card.cpp
|
||||
${CMAKE_SOURCE_DIR}/functions/viz/bar_chart.cpp
|
||||
|
||||
Reference in New Issue
Block a user