87b7ef45ff
Rebrand "Claude Usage" tab to "Monitor" and promote it to first/default tab in
the main TabBar. Monitor is the landing for the reactive loop (construir →
ejecutar → recopilar → analizar → mejorar).
UI additions:
- Local toolbar inside Monitor with date preset combo (1h / 24h / 7d / 30d /
All), manual Refresh button, and live LED + last-event-ts indicator.
- 5 KPI cards (was 4): added "Errors" derived from COUNT(*) FROM calls WHERE
success = 0 filtered by the active window.
- New sub-tab "Recent Executions" (first sub-tab) with columns: When,
Function, Tool, ms, OK (check/X colored), Error class. Backed by calls
table, sorted by ts DESC, limit 100, filtered by window.
- Violations sub-tab gains "When" column with formatted ts.
Data layer:
- data.h: RecentExecutionRow + window_secs + ws_connected/last_event_ts /
last_seen_call_id watermark on ClaudeUsageData.
- data_http.{h,cpp}: load_claude_usage_http now takes window_secs and embeds
ts_filter() in calls/errors/violations queries. total_errors populated.
recent_executions populated up to 100 rows. New standalone
load_recent_executions_http() for future WS-driven partial refetch.
- main.cpp: reload_data preserves window_secs across reloads; new
reload_monitor() does a Monitor-only refetch when the user changes the
window or clicks Refresh, without re-querying the full registry.
Wiring:
- views.h: draw_monitor + monitor_consume_reload_request() +
monitor_set_ws_state() exported. draw_claude_usage removed.
- views.cpp: render() consumes monitor_consume_reload_request each frame
and dispatches reload_monitor().
This is the UI half of issue 0086. The server-side WebSocket endpoint in
sqlite_api and the C++ WS client are next; the LED is wired to
monitor_set_ws_state but stays gray until those land.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
77 lines
3.8 KiB
C++
77 lines
3.8 KiB
C++
#pragma once
|
|
|
|
#include "data.h"
|
|
#include <string>
|
|
|
|
// Load all registry data via sqlite_api HTTP endpoint.
|
|
// api_url should be like "http://127.0.0.1:8484".
|
|
// Returns true on success.
|
|
bool load_registry_data_http(const std::string& api_url, RegistryData& out);
|
|
|
|
// Load projects list (con conteos) y huerfanas. No destruye el resto de
|
|
// campos de out, solo setea projects + orphan_*.
|
|
bool load_projects_http(const std::string& api_url, RegistryData& out);
|
|
|
|
// Load detalle de un proyecto (apps/analyses/vaults). Si id=="orphans"
|
|
// devuelve las entidades sin project_id.
|
|
bool load_project_detail_http(const std::string& api_url,
|
|
const std::string& id,
|
|
ProjectDetail& out);
|
|
|
|
// Load detalle completo de una funcion (codigo + documentacion + metadata).
|
|
// Usado por la pestana Explorer.
|
|
bool load_function_detail_http(const std::string& api_url,
|
|
const std::string& id,
|
|
FunctionDetail& out);
|
|
|
|
// Load lista plana de funciones para el Explorer (id, name, lang, domain,
|
|
// kind, purity, description, tested) — todas las funciones, no solo recientes.
|
|
bool load_all_functions_http(const std::string& api_url,
|
|
std::vector<FunctionRow>& out);
|
|
|
|
// Load tests unitarios asociados a una funcion (tabla unit_tests con FK
|
|
// function_id). Devuelve la lista vacia si la funcion no tiene tests.
|
|
bool load_unit_tests_http(const std::string& api_url,
|
|
const std::string& function_id,
|
|
std::vector<UnitTestRow>& out);
|
|
|
|
// Issue 0085d: Load Claude usage telemetry from ops:call_monitor (top
|
|
// functions, recent violations, copied code). Si la BD no esta disponible
|
|
// setea out.claude.available = false sin error.
|
|
//
|
|
// `window_secs`: ventana hacia atras desde now. 0 = sin filtro (All).
|
|
// Aplica a total_calls, total_errors, top_functions, recent_executions,
|
|
// recent_violations. total_versions/total_copies son acumulados (no filtran).
|
|
bool load_claude_usage_http(const std::string& api_url, RegistryData& out,
|
|
int window_secs);
|
|
|
|
// Variante legacy (window default 24h). Usar la version con window_secs.
|
|
inline bool load_claude_usage_http(const std::string& api_url, RegistryData& out) {
|
|
return load_claude_usage_http(api_url, out, 86400);
|
|
}
|
|
|
|
// Carga la ventana de "Recent Executions" (calls table) ordenada por ts DESC.
|
|
// Filtrada por window_secs (0 = sin filtro). limit = max filas (default 100).
|
|
bool load_recent_executions_http(const std::string& api_url,
|
|
int window_secs, int limit,
|
|
std::vector<RecentExecutionRow>& out,
|
|
long long& out_max_id);
|
|
|
|
// Operaciones de mutacion (thread-safe porque http_post ya lo es).
|
|
// Devuelven el body de respuesta en `out_body`. true si HTTP status 2xx.
|
|
bool http_post_reindex(const std::string& api_url, std::string& out_body);
|
|
bool http_post_add_app(const std::string& api_url,
|
|
const std::string& name, const std::string& lang,
|
|
const std::string& domain, const std::string& project,
|
|
const std::string& description,
|
|
std::string& out_body);
|
|
bool http_post_add_analysis(const std::string& api_url,
|
|
const std::string& name, const std::string& project,
|
|
const std::string& packages_csv,
|
|
const std::string& description,
|
|
std::string& out_body);
|
|
bool http_post_add_vault(const std::string& api_url,
|
|
const std::string& name, const std::string& project,
|
|
const std::string& path, const std::string& description,
|
|
std::string& out_body);
|