Files
registry_dashboard/CMakeLists.txt
T
egutierrez 9205567d5f 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>
2026-05-14 00:34:03 +02:00

62 lines
2.5 KiB
CMake

# SQLite3: prefer the target created by the top-level CMakeLists. If running
# stand-alone (without the parent project), fall back to building the amalgamation.
find_package(SQLite3 QUIET)
if(NOT SQLite3_FOUND AND NOT TARGET sqlite3_vendored)
# Build from amalgamation
set(SQLITE3_AMALG_DIR ${CMAKE_SOURCE_DIR}/vendor/sqlite3)
add_library(sqlite3_vendored STATIC ${SQLITE3_AMALG_DIR}/sqlite3.c)
target_include_directories(sqlite3_vendored PUBLIC ${SQLITE3_AMALG_DIR})
target_compile_definitions(sqlite3_vendored PRIVATE
SQLITE_THREADSAFE=1
SQLITE_ENABLE_FTS5
SQLITE_ENABLE_JSON1
)
add_library(SQLite::SQLite3 ALIAS sqlite3_vendored)
endif()
add_imgui_app(registry_dashboard
main.cpp
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
${CMAKE_SOURCE_DIR}/functions/viz/pie_chart.cpp
${CMAKE_SOURCE_DIR}/functions/viz/table_view.cpp
${CMAKE_SOURCE_DIR}/functions/viz/sparkline.cpp
${CMAKE_SOURCE_DIR}/functions/core/dashboard_panel.cpp
${CMAKE_SOURCE_DIR}/functions/core/dashboard_grid.cpp
# fps_overlay y tokens viven en fn_framework
${CMAKE_SOURCE_DIR}/functions/core/fullscreen_window.cpp
${CMAKE_SOURCE_DIR}/functions/core/badge.cpp
${CMAKE_SOURCE_DIR}/functions/core/empty_state.cpp
${CMAKE_SOURCE_DIR}/functions/core/page_header.cpp
# Fase 3: UI primitives (projects + reindex + add modals)
${CMAKE_SOURCE_DIR}/functions/core/button.cpp
${CMAKE_SOURCE_DIR}/functions/core/icon_button.cpp
${CMAKE_SOURCE_DIR}/functions/core/toolbar.cpp
${CMAKE_SOURCE_DIR}/functions/core/modal_dialog.cpp
${CMAKE_SOURCE_DIR}/functions/core/text_input.cpp
${CMAKE_SOURCE_DIR}/functions/core/select.cpp
${CMAKE_SOURCE_DIR}/functions/core/toast.cpp
${CMAKE_SOURCE_DIR}/functions/core/process_runner.cpp
${CMAKE_SOURCE_DIR}/functions/core/process_state_machine.cpp
${CMAKE_SOURCE_DIR}/functions/core/tree_view.cpp
)
target_include_directories(registry_dashboard PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/vendor
)
target_link_libraries(registry_dashboard PRIVATE SQLite::SQLite3)
# Sockets: ws2_32 on Windows, nothing extra on Linux
if(WIN32)
target_link_libraries(registry_dashboard PRIVATE ws2_32)
# GUI app: sin ventana de consola al lanzar (subsystem:windows / -mwindows)
set_target_properties(registry_dashboard PROPERTIES WIN32_EXECUTABLE TRUE)
endif()