From f7109a8ca02b2c82e65d2f50e3f83bdb2cadde86 Mon Sep 17 00:00:00 2001 From: Egutierrez Date: Thu, 14 May 2026 00:35:26 +0200 Subject: [PATCH] docs(monitor): bump to v0.4.0, update app.md with Monitor + WS section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - About info updated to reflect Monitor as primary tab and the WS feature set. - app.md gains a dedicated "Fase — Monitor tab + WebSocket live stream" section documenting the architecture, KPIs, WS hub design, fallback semantics, and the scope decisions (no TLS, skip Accept verification, WS client not yet extracted to cpp/functions/). - Roadmap items added: extract ws_client when a second consumer arrives, Sec-WebSocket-Accept verification, migrate to coder/websocket on the server. Co-Authored-By: Claude Opus 4.7 (1M context) --- app.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ main.cpp | 11 ++++++----- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/app.md b/app.md index 8d59640..3ed767b 100644 --- a/app.md +++ b/app.md @@ -95,6 +95,9 @@ cd cpp && cmake -B build/windows -S . -DCMAKE_TOOLCHAIN_FILE=toolchains/mingw-w6 - [ ] Filtros interactivos por lenguaje/dominio en sidebar - [ ] Busqueda FTS5 integrada via API - [ ] Detalles de funcion al hacer click en tabla +- [ ] Extraer ws_client a `cpp/functions/network/` cuando un segundo app C++ necesite WS +- [ ] SHA1 + Sec-WebSocket-Accept verification (hoy se confia en el handshake 101) +- [ ] Migrar `nhooyr.io/websocket` → `github.com/coder/websocket` (mismo paquete, deprecation upstream) ## Notas @@ -142,6 +145,54 @@ El cross-compile pasa de thread model `win32` a `posix` (`x86_64-w64-mingw32-g++ - `CMakeLists.txt` limpiado: `fps_overlay.cpp` y `tokens.cpp` ya viven en `fn_framework` — no listarlos explicitamente o el linker da multiple-definition. - 5 TTFs (Karla/Roboto/DroidSans/Cousine/Tabler) copiadas junto al exe via `add_imgui_app` post-build. +## Fase — Monitor tab + WebSocket live stream `[done 2026-05-14, issue 0086]` + +Rebranding "Claude Usage" → **Monitor**, ahora primera y por defecto en el TabBar. +Es el landing del bucke reactivo (construir → ejecutar → recopilar → analizar → mejorar). + +Nuevos elementos UI: +- **Toolbar interna** del Monitor con preset de ventana temporal (1h / 24h / 7d / 30d / All), + boton Refresh manual, LED `live`/`offline` con timestamp del ultimo evento WS. +- **5 KPI cards** (era 4): añadido "Errors" derivado de `COUNT(*) FROM calls WHERE success = 0` + filtrado por la ventana activa. +- **Sub-tab "Recent Executions"** (la primera) con columnas: When, Function, Tool, ms, OK, Error. + Backed by `calls` table, sorted by ts DESC, limit 100, filtrada por ventana. +- Violations sub-tab gana columna "When" con ts formateado. + +Pipeline en vivo (low-latency, push-based): + +``` +Hook PostToolUse ──► call_monitor CLI ──► INSERT calls (siempre, sincrono) + │ + ▼ + ops:call_monitor.db + ▲ + │ (ticker 250ms cuando subs>0) +sqlite_api /api/events/call_monitor ──► WS hub ──► subscribers (dashboards) +``` + +- **sqlite_api**: nuevo endpoint `GET /api/events/call_monitor`. Hub gestiona subscribers, + ticker arranca solo con >=1 sub (cero overhead si no hay dashboards). Cliente recibe + snapshot inicial (KPIs + 100 ultimas) y luego deltas (`id > watermark`). Intervalo + adaptativo: 250ms activo → 2s idle (tras 30s sin eventos). +- **registry_dashboard**: cliente WS minimal RFC6455 en `ws_client.{h,cpp}` (no TLS, + thread propio, reconnect exponencial 0.5s → 8s). `main.cpp` consume deltas y los aplica + a `g_data.claude` (incrementa KPIs, anade filas, dedup por id). +- **Fallback**: si WS cae, los datos siguen registrandose en SQLite via call_monitor CLI. + Al reconectar, el cliente puede mandar `{"watermark": N}` para reanudar sin perder eventos. + +Cambios en `data.{h,cpp}` y `data_http.{h,cpp}`: +- `RecentExecutionRow`, `window_secs`, `ws_connected`, `last_event_ts`, `last_seen_call_id` + en `ClaudeUsageData`. +- `load_claude_usage_http(api, out, window_secs)` filtra `calls` y `violations` por ventana. +- `load_recent_executions_http()` standalone para refetch parcial (preparado para WS, + no esta cableado todavia — actualmente las deltas WS bastan). + +Decisiones de scope: +- Sec-WebSocket-Accept verification se omite (server controlado, localhost only). +- TLS fuera (ws://, no wss://). +- WS client no extraido al registry todavia: hasta que un segundo app C++ lo necesite. + ## Notas — Settings submenu + Git column (sesion 2026-04-28) - `fn_ui::app_menubar` reemplaza el item plano `Settings...` por un `BeginMenu("Settings")` con dos subitems: `Settings...` (existente) y `About...` (nuevo modulo `app_about_cpp_core`). El registry_dashboard cablea la info via `fn_ui::about_window_set_info("fn_registry Dashboard", "0.2.0", "Dashboard ImGui...")` antes de `fn::run_app`. diff --git a/main.cpp b/main.cpp index b2163eb..887da31 100644 --- a/main.cpp +++ b/main.cpp @@ -262,11 +262,12 @@ int main(int argc, char** argv) { // Info de la ventana About (submenu Settings → About...) fn_ui::about_window_set_info( "fn_registry Dashboard", - "0.3.0", - "Dashboard ImGui para visualizar el estado del fn_registry. " - "Consume datos via sqlite_api HTTP (fallback a SQLite directo). " - "KPIs con sparkline, charts con leyenda, tablas, altura responsive, " - "Status panel en Settings, multi-viewport, dashboard_panel en views." + "0.4.0", + "Dashboard ImGui del fn_registry. Pestana Monitor por defecto con KPIs " + "live (Calls / Errors / Violations / Copies / Versions), Recent Executions " + "con timestamp, filtro de ventana (1h/24h/7d/30d/All) y WS subscription " + "al hub /api/events/call_monitor de sqlite_api. Resto de tabs (Dashboard, " + "Explorer, Projects, Apps, Analysis, Types) sin cambios." ); // Seccion Status dentro de la ventana Settings (submenu Settings → Settings...).