Remove the browser UI, its Python server and the web API contract test. Add the Qt6 tray app (status, findings, process search, policy controls, notifications) and EvidenceStore, the read-only view of the daemon's evidence that the app and MCP server share. The GUI demo config becomes strawberry.demo.conf. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
2 KiB
C++
63 lines
2 KiB
C++
#ifndef STRAWBERRY_APP_TRAY_STATE_HPP
|
|
#define STRAWBERRY_APP_TRAY_STATE_HPP
|
|
|
|
// Pure decision logic for the tray indicator: no Qt, no I/O, unit-tested.
|
|
// Scanner-health rules are shared with the MCP server (scanner_health.hpp).
|
|
|
|
#include "strawberry/scanner_health.hpp"
|
|
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace strawberry::app {
|
|
|
|
using strawberry::DaemonSnapshot;
|
|
using strawberry::scanner_problems;
|
|
|
|
struct FindingSummary {
|
|
std::string id;
|
|
std::string title;
|
|
std::string severity;
|
|
int64_t last_seen = 0;
|
|
};
|
|
|
|
/// finding id -> last_seen value the user acknowledged (or was notified of).
|
|
using AckMap = std::map<std::string, int64_t>;
|
|
|
|
enum class TrayLevel {
|
|
unknown, // gray: daemon unreachable
|
|
ok, // green
|
|
warning, // yellow: degraded scanner or unseen lower-severity finding
|
|
alert, // red: unseen high/critical finding
|
|
};
|
|
|
|
struct TrayState {
|
|
TrayLevel level = TrayLevel::unknown;
|
|
std::string tooltip;
|
|
std::vector<std::string> problems; // degraded-scanner reasons
|
|
int unseen_alerts = 0; // unseen high/critical
|
|
int unseen_other = 0;
|
|
};
|
|
|
|
int severity_rank(const std::string& severity);
|
|
bool is_alert_severity(const std::string& severity);
|
|
|
|
/// Unseen = never acknowledged, or new evidence since acknowledgement.
|
|
bool is_unseen(const FindingSummary& finding, const AckMap& seen);
|
|
|
|
TrayState evaluate_tray(const DaemonSnapshot& snapshot,
|
|
const std::vector<FindingSummary>& findings,
|
|
const AckMap& seen,
|
|
uint64_t previous_scan_errors);
|
|
|
|
/// High/critical findings that need a desktop notification (not yet
|
|
/// notified at their current last_seen, and not already seen).
|
|
std::vector<FindingSummary> findings_to_notify(const std::vector<FindingSummary>& findings,
|
|
const AckMap& seen,
|
|
const AckMap& notified);
|
|
|
|
} // namespace strawberry::app
|
|
|
|
#endif // STRAWBERRY_APP_TRAY_STATE_HPP
|