#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 #include #include #include 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; 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 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& 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 findings_to_notify(const std::vector& findings, const AckMap& seen, const AckMap& notified); } // namespace strawberry::app #endif // STRAWBERRY_APP_TRAY_STATE_HPP