#pragma once
#include <cstdint>

enum class DisplayPage : uint8_t { OVERVIEW, CPU, MEMORY, DISK, NETWORK, PI, COUNT };

constexpr bool page_uses_server_state(DisplayPage page) {
    return page >= DisplayPage::OVERVIEW && page <= DisplayPage::NETWORK;
}

// Page::PI backs both the Agent page and the Watch. Only the Watch shows
// derived server state (Host/Codex rows); the Agent page must not repaint on a
// server snapshot. Callers pass the App so the distinction stays explicit.
enum class ShellApp : uint8_t { Watch, Agent, Monitor, Help };

constexpr bool server_snapshot_needs_redraw(DisplayPage page, bool overlay) {
    return page_uses_server_state(page) && !overlay;
}

// The Watch redraws only when a derived value it displays actually changed.
// `changed` is computed by the caller from the derived state, never from the
// raw snapshot, so an identical 2 s frame cannot cause a repaint.
constexpr bool watch_snapshot_needs_redraw(DisplayPage page, ShellApp app, bool overlay, bool changed) {
    return page == DisplayPage::PI && app == ShellApp::Watch && !overlay && changed;
}

constexpr bool agent_snapshot_needs_redraw(DisplayPage page, bool overlay, bool changed,
                                          ShellApp app=ShellApp::Agent) {
    return page == DisplayPage::PI && app == ShellApp::Agent && !overlay && changed;
}
