chore: auto-commit (4 archivos)

- data.h
- data_http.cpp
- main.cpp
- views.cpp

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-14 02:06:46 +02:00
parent 5c53cfcb68
commit 00ee6a93e3
4 changed files with 315 additions and 17 deletions
+28 -2
View File
@@ -86,6 +86,8 @@ static bool apply_ws_message(const std::string& raw) {
std::vector<RecentExecutionRow> incoming;
incoming.reserve(msg["calls"].size());
int new_errors = 0;
int new_mcp = 0;
int new_reg_hits = 0;
for (const auto& c : msg["calls"]) {
RecentExecutionRow row;
row.id = c.value("id", 0LL);
@@ -94,15 +96,39 @@ static bool apply_ws_message(const std::string& raw) {
row.tool_used = c.value("tool_used", "");
row.duration_ms = c.value("duration_ms", 0);
row.success = c.value("success", true);
row.error_class = c.value("error_class", "");
row.session_id = c.value("session_id", "");
row.error_class = c.value("error_class", "");
row.error_snippet = c.value("error_snippet", "");
row.command_snippet = c.value("command_snippet", "");
row.session_id = c.value("session_id", "");
if (!row.success) new_errors++;
// Registry-aware tools: mcp*, heredoc*, fn_cli_run, fn_run_cli.
const auto starts_with = [](const std::string& s, const char* p) {
size_t lp = std::strlen(p);
return s.size() >= lp && std::memcmp(s.c_str(), p, lp) == 0;
};
if (starts_with(row.tool_used, "mcp") ||
starts_with(row.tool_used, "heredoc") ||
row.tool_used == "fn_cli_run" ||
row.tool_used == "fn_run_cli") {
new_mcp++;
}
if (!row.function_id.empty()) new_reg_hits++;
incoming.push_back(std::move(row));
}
if (type == "delta") {
g_data.claude.total_calls += static_cast<int>(incoming.size());
g_data.claude.total_errors += new_errors;
g_data.claude.total_mcp += new_mcp;
// registry_pct se recalcula sobre el total acumulado tras el delta.
// Aproximacion: prev_pct * prev_total + new_reg_hits / new_total.
int prev_total = g_data.claude.total_calls - static_cast<int>(incoming.size());
int prev_hits = static_cast<int>(g_data.claude.registry_pct *
static_cast<double>(prev_total) / 100.0 + 0.5);
int total_hits = prev_hits + new_reg_hits;
g_data.claude.registry_pct = (g_data.claude.total_calls > 0)
? 100.0 * static_cast<double>(total_hits) / static_cast<double>(g_data.claude.total_calls)
: 0.0;
}
// Prepend (newer al frente). Para delta: filas vienen ASC del server,